Bill de Blasio, the unabashed progressive who lit up the New York mayoral campaign, faced a nervous wait to find out whether he would be the Democratic candidate on Wednesday as he hovered around the 40% needed to win the nomination outright.

A pledge by second-placed Bill Thompson to wait for the official totals mean it could be days before De Blasio finds out if he will run against Joe Lhota, who secured the Republican nomination.

But while the precise result may still be in the balance but the message from New York Democrats could not be more clear. The battle to succeed Michael Bloomberg as the next mayor of the biggest city in the United States will be an ideological fight led by a candidate determined to distance himself as far as possible from the billionaire incumbent.

Christine Quinn, the city council leader and Bloomberg ally who started the race as frontrunner, bowed out in a dismal third place with only 15% of the vote, her hopes to break ground as the first woman and first gay mayor dashed.

The final result will not be known until next week at the earliest: New York's 1960s lever-pull voting machines will not be opened until Friday, and 19,000 paper ballots not due to be counted until Monday. If the result is still close – and New York's Board of Elections is notoriously inefficient – Thompson could demand a recount. He declined to concede the race on Wednesday, vowing to wait until the official result.

Thompson told supporters on Tuesday night that he would wait for the official count instead of conceding defeat. "We took Mike Bloomberg on and we almost beat him. Now we're gonna finish what we started," said Thompson, who was the Democratic nominee in 2009 but lost to the incumbent billionaire.

"Every voice in New York City counts and we're gonna wait for every voice to be heard. We're gonna wait for every vote to be counted. So my friends this is far from over."

According to tallies collated by WNYC radio, Thompson had 26.10% of the vote on Wednesday morning, with Quinn in third place on 15.47%. Anthony Weiner, who had also looked strong earlier in the campaign, suffered the ignominy of a fifth-place finish with just 4.91% of the vote. After a tear-filled concession speech, in which his wife Huma Abedin was notable by her absence, Weiner made an inglorious exit: a picture showed him giving a one-fingered gesture of insult to reporters as he was driven away.

Valerie Vasquez, director of communications at the city's board of elections, confirmed that BOE staff would open the lever voting machines on Friday to get the official totals and stressed that current numbers are unofficial. She said the official count is done to safeguard against possible "human error" in the unofficial count – conducted by polling staff on Tuesday night.

The lever machines were wheeled out of retirement after the board of elections determined that its modern machines would not be able to be reset in time for a runoff vote, but problems were reported with some machines on Tuesday.

"There were isolated instances through the city. I would not say it was widespread," Vasquez said. "We did have instances where the machines did not work or had to be repaired or replaced, but in those instances no one was ever disenfranchised there was always an availability for an emergency ballot for a voter."

Amid the uncertainty over whether De Blasio would face a run-off with Thompson on 1 October, it was clear that Democratic New Yorkers had resoundingly voted for change. Exit polls indicated that seven out of 10 Democratic primary voters – the lion's share in this very liberal city – wanted to see a new direction at city hall, even though about half thought that the incumbent Michael Bloomberg had been doing a good job.

De Blasio's triumph has been attributed in no small part to his overt positioning as the anti-Bloomberg candidate, encapsulated in his campaign mantra "a tale of two cities" that played on the incumbent's personal wealth and his friendliness towards Wall Street. It was an extraordinary rise from relative nobody four weeks ago to a 15-point lead over the second-placed Thompson.

His early rival, Quinn, tried to muddy his campaign by portraying him as a flip-flopper on term limits: De Blasio promised to extend limits for city council members when he was wooing them in a run to be speaker of the council in 2005, then opposed Bloomberg's bid for a third term when New York mayors were limited to two.

But in the end his message was simpler: Quinn, a close ally of Bloomberg, had facilitated Bloomberg's unprecedented extra term in office and, in terms of policies, promised more of the similar, if not the same.

On a more personal level, De Blasio played the oldest politician's trick in the book – he surrounded himself with his loving family. Which, in this case, included his African American wife Chirlane McCray, 19-year-old daughter Chiara and 16-year-old son Dante, whose Afro hairstyle became a symbol of De Blasio's campaign and who appeared in a widely circulated video saying that his father was the "only Democrat with the guts to really break from the Bloomberg years".

De Blasio's seemingly unstoppable ascension holds up the intriguing prospect of an ideologically intense general mayoral election on 5 November of the sort not seen in New York for decades.

If De Blasio secures his party's nomination and runs on the overtly liberal platform that he laid out in the primary, it will pitch him against the Bloomberg-friendly emphasis on wealth-creation and high-end investment promoted by Lhota, Tuesday night's Republican victor.

Lhota, the former chairman of the Metropolitan Transportation Authority, which runs the New York subway, has already declared his intention to go after De Blasio as a radical firebrand and class-warrior, saying in his victory speech that the Democrat's politics was the kind that "brought our city to the brink of bankruptcy and rampant civic decay."

De Blasio and Lhota have already clashed at the polls, albeit from the sidelines. In the 1989 mayoral election De Blasio was part of the winning campaign team of the Democratic candidate David Dinkins, while Lhota acted as an economics adviser to the Republican Rudy Giuliani.

It remains to be seen whether Lhota's aggressive approach will work. New York has been transformed over the past 25 years, with its finances in much better shape and its reputation for crime and anarchy dissipated.

The legendary tribalism of New York politics, in which voters could be predicted to move in solid and often antagonistic blocs, has also been substantially overcome – not least by De Blasio himself. Exit polls showed that he had achieved what used to be considered in this city the impossible: he attracted majority support from almost all demographic groups.

That included black people and Hispanics as well as whites; women as well as men, gays as well as straights, residents from all five boroughs, as well as Protestants, Catholics and Jews. (Asians voted overwhelmingly for John Liu, the comptroller, or city auditor.)

Slate columnist June Thomas wrote of De Blasio: "He didn't just get more LGBT votes than the lesbian candidate, he got more votes in majority black precincts than Thompson, the African American candidate, and he drew more women voters than the female candidate."

The other imponderable now is how Bloomberg will react to De Blasio's likely Democratic candidacy and the challenge it poses to the incumbent's legacy. The present mayor has made it plain that he is not a fan of the Democratic frontrunner, going so far as to denounce his campaign as "racist".

But at a time when New Yorkers appear highly divided by the achievements of the 12 Bloomberg years, any intervention by the current mayor on the side of Lhota would run the risk of backfiring.