NEW YORK — The race to succeed Mayor Michael Bloomberg is shaping up as a referendum on the 12-year legacy of the billionaire who guided the nation’s biggest city through the aftermath of 9/11 and the meltdown on Wall Street.
The top vote-getter in Tuesday’s Democratic primary, Public Advocate Bill de Blasio, railed against the mayor’s pro-police, pro-development, pro-business, pro-trickle-down politics.
On the Republican side, Joe Lhota, a one-time deputy mayor to Rudolph Giuliani, handily won his party’s nomination after tying himself closely to many of Bloomberg’s policies.
‘‘It is clear that the narrative going forward is that this election is a verdict on Bloomberg,’’ said Jeanne Zaino, a New York University political science professor.
Bloomberg, a Republican-turned-independent who made his vast fortune from the financial news company that bears his name, is leaving office after three terms.
The Democrat most closely allied with Bloomberg, City Council Speaker Christine Quinn, was crushed in the mayoral primary, finishing a distant third amid polling that showed that New Yorkers are eager for a change after more than a decade with Bloomberg in charge.
But those same polls showed that most New Yorkers still generally approve of Bloomberg’s tenure.
‘‘If you were dropped into the Democratic primary from space, you’d think that voters simply hated Bloomberg,’’ Zaino said. ‘‘It’s a more complex picture than that.’’
Whether de Blasio will, in fact, be the Democratic nominee in the November election remains to be seen.
With 99 percent of precincts reporting, he had 40.3 percent of the vote, just above the 40 percent needed to win the nomination and avoid an Oct. 1 runoff against second-place finisher Bill Thompson.
Election officials said that it will be at least Monday before all votes are counted.
Neither de Blasio nor Thompson addressed the election Wednesday, as both followed city tradition by abstaining from campaigning on Sept. 11.
De Blasio ran as a Bloomberg antagonist, putting the fight to end economic inequality at the heart of his campaign and accusing the mayor of creating a ‘‘tale of two cities’’ by favoring real estate developers and Wall Street.
With far greater clarity than his Democratic rivals, he positioned himself as an opponent of the New York Police Department’s stop-and-frisk program of aggressively questioning people deemed suspicious.
The program’s critics said it unfairly targeted minorities, while its supporters — including Bloomberg — credited it with helping to drive crime down to historic lows.
When a federal judge ruled stop-and-frisk was being conducted improperly, de Blasio got far more of a lift than Quinn or Thompson.
Bloomberg himself underscored the differences between himself and de Blasio in a New York Magazine interview published last week.
He said de Blasio was running a ‘‘racist’’ campaign by highlighting his interracial family.
And Bloomberg ripped de Blasio’s ‘‘tale of two cities’’ theme, saying of the rich: ‘‘We want these people, and why criticize them? Wouldn’t it be great if we could get all the Russian billionaires to move here?’’