New York City Public Advocate Bill de Blasio, once seen as a long-shot candidate, held a commanding lead over his rivals in the Democratic primary for mayor late Tuesday night.

Returns suggested that de Blasio, who campaigned to end aggressive police tactics like stop-and-frisk and to ease the economic plight of the city’s working classes, could finish with at least 40 percent of votes, meaning he would avoid an Oct. 1 runoff against the runner-up. But the final result was uncertain late Tuesday night.

If de Blasio reaches that threshold, Democratic voters will have chosen one of the most liberal candidates in this year’s field to reclaim a mayor’s office that had been out of the party’s hands since 1993 — first with Rudy Giuliani’s eight years, and the last dozen years with Michael Bloomberg.

“It goes against all the conventional wisdom,” said Democratic consultant and former City Council staffer Evan Thies of de Blasio’s success. “It breaks with the idea that identity politics is the one constant truth of local politics. He crossed over demographic lines in a historic victory for the city.”

Elections officials, however, were not done with counting, and there remained a chance that de Blasio could fall below 40 percent, meaning he and the second-place finisher, former Comptroller Bill Thompson, would meet in the runoff. City Council Speaker Christine Quinn finished third and conceded defeat. MORE