NEW YORK (AP) — Voters were not in a forgiving mood for two brash New Yorkers whose once-promising political careers were shattered by sex scandals.

With nearly all precincts reporting Tuesday night, former congressman Anthony Weiner was in fifth place in the city's Democratic mayoral primary, with about 5 percent of the vote.

Former Gov. Eliot Spitzer lost the Democratic primary contest for city comptroller to Scott Stringer, the Manhattan borough president. Stringer took 52 percent of the vote to Spitzer's 48 percent.

Weiner had been in political exile since he resigned from Congress in 2011 for sending women lewd online messages and pictures. He got into the mayor's race in May, and aside from a few dust-ups with hecklers, was largely well-received at first, holding the lead in polls for most of June and July.

But after an obscure gossip website named The Dirty released X-rated exchanges between Weiner and a 23-year-old woman that took place well after the candidate quit the House of Representatives, Weiner —and his sexting pseudonym, Carlos Danger, once again became a national punchline.

Spitzer resigned as governor in 2008 after admitting he paid for sex with call girls. In exile, he bounced around television as a pundit. Then, just four days before the filing deadline, he announced he was running for comptroller.

He took an early lead in the polls, but the race tightened dramatically in recent weeks as the Democratic establishment rallied around Stringer.

Weiner was dogged until the very end of his mayoral run by the sexting scandal that he never was able to escape.

Outside a "victory" party where supporters mourned his disappointing primary finish, cameras were crowded around Sydney Leathers, the 23-year-old woman whose sexting with the former congressman brought his once-high-flying campaign to a screeching halt.

"Why not be here?" Leathers asked reporters. "I'm kind of the reason he's losing. So, might as well show up."

To avoid an embarrassing confrontation, Weiner's staff sneaked him into his own event through a side entrance. His wife, Huma Abedin, who stood by his side at the height of the scandal, was nowhere to be seen. Abedin served as a top aide to former Secretary of State Hillary Rodham Clinton.

And after a concession speech in which he got choked up as he spoke of family, Weiner was caught by a photographer giving an obscene gesture to reporters as he was driven away.

Leathers, who has launched a porn career since the scandal broke, said Weiner needed "to stop being an embarrassment to the city of New York. He's going to continue this behavior. If it's not going to be me, it's going to be some other girl."

For his part, Weiner acknowledged in his at-times emotional concession speech that he was an "imperfect messenger."

Unlike Weiner, who made a point of fielding voters' questions about his scandal, Spitzer apologized a few times and then refused to talk about it.

He largely eschewed retail campaigning — situations that could have led to awkward exchanges with voters — in favor of national TV interviews and a big television ad campaign, financed with his own millions.

But he could not avoid all mention of the scandal. The city's tabloids hounded him about the state of his marriage; Spitzer said he was still married, but his wife never appeared on the campaign trail.

"All of us should serve, participate," Spitzer told supporters in his concession speech. "I intend to do so in different ways."