Anthony Weiner’s clownish run for mayor ended like a three-ring circus last night, as he admitted to a crushing defeat at a campaign party that ended with him flipping the bird at a reporter.

“I have to say we had the best ideas, but sadly, I was the imperfect messenger,” said Weiner, who got only 4.9 percent of the vote in the Democratic primary.

The night began with yet another humiliation for “Carlos Danger” when Sydney Leathers, the porn star who sunk his campaign by exposing their secret sexting affair, showed up at the Midtown bar where he was speaking.

They never met, because the disgraced former congressman sneaked into his own event through the back door like a party crasher.

“He needs to stop being an embarrassment to the City of New York. He should have dropped out of the race a long time ago, in my opinion,” said Leathers, who wore a red dress that showed off her new breast implants.

One person who didn’t show up was Weiner’s wife, Huma Abedin, who sources said was in the Hamptons.

As he left Connolly’s bar, Weiner got mad at the press — obviously the source of all of his woes — and brought his sleazy campaign to a classless end by flashing his middle finger at a WNBC/Channel 4 reporter while he was being driven away. NY1 captured the moment and posted a snap to its Twitter page.

