NEW YORK -- Fernando Ferrer teetered on the edge of victory yesterday over three other Democrats competing in their party's primary for the chance to wage an underdog campaign against Mayor Michael Bloomberg, a billionaire Republican who enjoys broad support in this overwhelmingly Democratic city.
With all but 10 precincts reporting, Ferrer had 40 percent of the vote, ahead of US Representative Anthony D. Weiner's 29 percent. C. Virginia Fields, Manhattan borough president, had 16 percent, and City Council Speaker Gifford Miller had 10 percent. Fields and Miller conceded.
Ferrer needed 40 percent to avoid a runoff with Weiner, and the outcome might not be known for several days until every vote is counted, including more than 25,000 absentee ballots. The winner goes into the general election Nov. 8 against Bloomberg, who is more popular than all four Democrats in recent polls.
Also on the New York ballot, Manhattan District Attorney Robert Morgenthau defeated former judge Leslie Crocker Snyder, a no-nonsense former judge who raised the 86-year-old incumbent's age and eight-term tenure as campaign issues. Morgenthau was the model for the fictional television prosecutor Adam Schiff on the program ''Law and Order."
Ferrer's run is his third try for mayor after losing the primary in 1997 and a runoff in 2001 to then-Public Advocate Mark Green. The primary that year was supposed to take place on Sept. 11, but was rescheduled in the chaos of the terrorist attacks. Green eventually lost to Bloomberg, who was considered a long shot until he was endorsed by Rudolph Giuliani as the fires still raged in the ruins of the World Trade Center.
Ferrer, the former Bronx borough president, would be the city's first Latino mayor if elected.
A potential runoff between Ferrer and Weiner promised to be lively. While all four Democrats largely avoided attacking one another leading up to the primary, there were occasional tangles between the two men.
As votes are counted, the two are not likely to waste precious time, campaigning as if there will be a runoff, which would be held Sept. 27.
Some Democratic leaders were concerned a runoff would divide the party and weaken their chances against Bloomberg, who is buoyed by high approval ratings.
Not to be upstaged, Bloomberg threw an election night party in Brooklyn, even though he did not face a challenger in the primary.
''Someone told me there was a primary contest going on tonight. Is that right? I love primary night, especially when I don't have one," Bloomberg cracked. ''If we work hard over the next eight weeks . . . I'll tell you who the real winner's going to be on Nov. 8, the people of New York."
Polls leading up to the primary have indicated that a majority of New Yorkers believe Bloomberg will beat the Democratic challenger. He spent $74 million to get elected in 2001, and has pledged he will spend whatever it takes to win this year.
There are 2.6 million registered Democrats in New York City (and 477,000 Republicans), but the Board of Elections reported light turnout as the polls closed last night.
Bloomberg himself was a lifelong Democrat until he switched parties in 2001 to avoid a crowded ticket.
He is a moderate who backs abortion rights and has the support of some groups that traditionally back Democrats, such as the city's largest labor union, District Council 37.