Updated 2:15 a.m. ET
NEW YORK Public Advocate Bill de Blasio completed his surge from seemingly nowhere in New York City's mayoral primary Tuesday by taking a commanding lead on his Democratic opponents, hovering near the threshold needed to avoid a runoff.
Former Metropolitan Transit Authority Chairman Joe Lhota easily won the GOP nomination, capping a chaotic primary to succeed 12 years of Mayor Michael Bloomberg.
The night also marked the unceremonious end to the bid by a City Council leader trying to become the first female and openly gay mayor, and to the political comebacks of scandal-scarred candidates Anthony Weiner and Eliot Spitzer.
"We are better as a city when we make sure that everyone has a shot," de Blasio told his raucous Brooklyn victory party, emphasizing his campaign theme of combatting income inequality. "We begin tonight."
With 97 percent of precincts reporting, de Blasio had about 40.2 percent of the total vote. He needs to stay above 40 percent in order to avoid triggering an automatic Oct. 1 runoff. If he cannot, he would face former city Comptroller Bill Thompson, who has 26 percent.
Council Speaker Christine Quinn was third at 15 percent, followed by current city Comptroller John Liu at 7 percent and Weiner at 5 percent.
Elections officials are expected to count an additional 30,000 or more votes in coming days as absentee ballots arrive by mail and paperwork comes in from voters who had problems at the polls. A final result may not be known for 10 days.
With de Blasio so close to 40 percent, Democratic leaders may pressure Thompson to drop out in the name of party unity. But Thompson made it clear Tuesday that he wanted to contest the runoff.
"Three more weeks! Three more weeks!" chanted Thompson, the party's 2009 nominee, referring to the campaign sprint before the potential runoff. "This is far from over."
Exit polling shows de Blasio would handily defeat Thompson in a runoff, 52 to 34 percent, with 9 percent saying they'd stay home.
De Blasio's rise in the race to succeed Bloomberg was as sudden as it was unexpected.
Not even two months ago, he was an afterthought in the campaign, but surged in part thanks to an ad blitz that centered on his interracial family, his headline-grabbing arrest while protesting the possible closure of a Brooklyn hospital and the defection of Weiner's former supporters in the wake of another sexting scandal.
Exit polling showed the appeal of de Blasio, who holds the position of the city's official watchdog, to be broad-based: He was ahead in all five boroughs; was even with Thompson, the only African-American candidate, with black voters; and was ahead of Quinn, the lone woman in the race, with female voters. He also led Quinn, who is openly gay, among gay voters.
The voter interviews were conducted by Edison Media Research for The Associated Press and other news organizations.
In a speech to his supporters, notes CBS New York station WCBS-TV, de Blasio talked about the January day when he announced his candidacy.
"That day, we said that New York had become a tale of two cities," de Blasio said, "one where the very wealthy had not only rebounded from the Great Recession, but where life couldn't get much better for them. And we acknowledged that there was another New York, a New York where nearly half our citizens are living at or near the poverty line, where luxury condos had replaced community hospitals, where proactive policing had somehow slipped quietly into racial profiling."
The winner of any runoff contest will face Lhota in the Nov. 5 general election. Lhota, the ex-MTA chairman and a former deputy mayor to Rudolph Giuliani, defeated billionaire grocery magnate John Catsimatidis for the GOP nod.
In the closely watched race for city comptroller, Manhattan Borough President Scott Stringer defeated Spitzer, who was seeking a return to politics after resigning as New York's governor in 2008 amid a prostitution scandal.
The winner of the mayor's race in November will assume the helm of the nation's largest city at a critical juncture, as it experiences shrinking crime rates yet widening income inequality, and as the nearly completed One World Trade Center building symbolizes a new era after the terrorist attacks of 2001.
Bloomberg, the businessman Republican-turned-independent, is completing his third term. While the city's registered Democrats outnumber Republicans 6 to 1, the GOP's recent success in mayoral elections has been largely attributed to a crime epidemic, the aftermath of the Sept. 11 attacks or other extraordinary circumstances.
Nearly three-quarters of Democratic primary voters say the next mayor ought to move away from Bloomberg's policies, according to the exit polls.
And De Blasio, 52, has fashioned himself as the cleanest break from the Bloomberg years, proposing a tax on the wealthy to fund universal pre-kindergarten and changes to city police practices he says discriminate against minorities.
"I'm a lefty and I've had enough of the righties," said Jessica Safran, a business consultant from the Boerum Hill section of Brooklyn who voted for de Blasio. "Even if de Blasio moves to the center if he gets elected, he'll be closer to the positions I want than the others."
All the candidates were hosting election night rallies in venues across the city. Each gathering went silent for 15 minutes when President Barack Obama addressed the nation on the situation in Syria.
Quinn was the front-runner for much of the year, boasting the biggest campaign war chest and strong establishment backing. But she was dogged by her support to change term limits to let Bloomberg run again in 2009, a decision unpopular with liberals who make up the bulk of Democratic primary voters.
Turnout appeared light, but the city's complaint line received several thousand voting-related calls. Many reported jams and breakdowns in the antiquated lever machines, which were hauled out of retirement to replace much-maligned electronic devices.
The mayoral campaign was waged in hundreds of candidate forums and across millions of dollars of TV ads and was largely fought on the legacy of the Bloomberg era. Substantial policy differences were scarce among the Democrats, who agreed that the school system needed an overhaul, that the city's poor had been forgotten, and thatamid claims that police unfairly targeted blacks and Latinos.
Weiner surprisingly entered the race in May after being in political exile since resigning from Congress in 2011 upon admitting to lewd online exchanges with women who were not his wife.
His candidacy sparked curiosity and popular interest, and he immediately shot to the top of the polls. But support collapsed almost as quickly when he revealed in July that he continued the online behavior even after his resignation from federal office.
On the Republican side, the candidates largely pledged to follow Bloomberg's lead, focusing on maintaining the city's record low crime rates. Lhota led the race from start to finish, fending off Catsimatidis' self-financed, unorthodox bid. Catsimatidis spent more than $4 million of his own money but was unable to stage a serious challenge.