Also potentially harmful to Mr. Klein was the barrage of negative headlines in recent months, including an accusation of sexual misconduct against him and a state Board of Elections finding of improper campaign financing.
The challengers’ victories boosted the emerging progressive narrative that the old political model — buying expensive television ads, cozying up to real estate, corralling union support — had been displaced by vigorous grass-roots organizing.
Each challenger outspent his or her opponent on Facebook advertisements, sometimes by a huge margin. Ms. Biaggi and her allies spent between $14,500 and $93,800 on Facebook ads since May, while Mr. Klein and his supporters spent between $2,400 and $14,796.
Ms. Salazar adopted similar tactics against Mr. Dilan, who although he was not a member of the I.D.C. was successfully portrayed as another out-of-touch corporate Democrat. The Democratic Socialists of America, of which Ms. Salazar is a member, deployed its full organizing power for her in Brooklyn.
A string of negative headlines about Ms. Salazar in the final weeks of the campaign — suggesting that she had misled reporters and voters about her immigration status, religious background and socioeconomic status — seemed to have little impact.
Still, Lina Newton, a political-science professor at Hunter College, noted the geographic limitations to the grass-roots organizing that has propelled the insurgent candidates to victory. Ms. Nixon, after all, deployed similar tactics in a statewide race to no avail.
“Personal outreach is much more important on a local level,” Professor Newton said.
And on that local level on Thursday, it was potent. Ms. Biaggi, in an interview, gestured to the sneakers on her feet, calling the previous hours “the most exhausting day in my life.”
For Mr. Klein, she had a simple message: “It was a tough fight. And, I should also say, we should thank him for his service,” she said. “But his time is up.”