New York City Public Advocate Bill de Blasio is just over the threshold he needs to avoid a runoff in the Democratic primary for New York City mayor, but it remains to be seen whether the margin will hold.

De Blasio is at 40.2 percent of the vote with 98 percent of precincts reporting. If he fails to clear 40 percent, he would face a runoff with 2009 Democratic nominee Bill Thompson, who is in second place at 26 percent.

The city will conduct a recount to determine whether a runoff is required.

City Council Speaker Christine Quinn, the early favorite in the race, wound up with less than 16 percent of the vote, while city comptroller John Liu was at 7 percent and former congressman Anthony Weiner had less than 5 percent.

Shortly after midnight, de Blasio spoke to supporters and told them his campaign would continue to be the antithesis of three-term Mayor Michael Bloomberg's (I) tenure.

“To the people of New York, I say thank you,” de Blasio said. He added that he would take his “unapologetically progressive alternative” to Bloomberg’s policies to the “next round” of the campaign.

The question is whether the next round is a runoff or the general election, which would pit him against GOP nominee Joe Lhota, who defeated businessman John Catsimatidis 53-41.

If de Blasio and Thompson do go to a runoff, it would be held in three weeks' time, on Oct. 1.

The city board of elections will conduct a recount, given how close de Blasio is to the runoff threshold. Absentee and overseas ballots still need to be counted as well. The process is expected to stretch into next week.

Polls suggest de Blasio would enter the runoff race with an advantage, according to polls. A Quinnipiac poll last week showed him leading Thompson, who narrowly lost to Bloomberg in 2009, 56-36 in a hypothetical runoff.

Thompson, however, did over-perform some late polls of the race on primary day.

The matchup between de Blasio and Thompson would be an interesting one -- particularly given the role that race has played in the campaign so far.

Thompson has campaigned as the "first African American comptroller in the history of our city," while Bloomberg has accused de Blasio of exploiting his biracial family (his wife is black) for the benefit of his campaign.

Primary day was punctuated by Weiner's descent, as he finished a distant fifth following a bizarre final few weeks of the campaign. By the end of the night, a photographer shot a photo of Weiner extending his middle finger at a reporter while driving away from his victory party.