NEW YORK — Ex-congressman and struggling mayoral candidate Anthony Weiner said Wednesday a video showing him in a shouting match with a bakery customer is just an example of him putting a heckler in his place.

The two-minute video shows Weiner, surrounded by reporters and campaign supporters in Brooklyn’s Orthodox Jewish neighborhood of Borough Park, going back inside the bakery after someone yells, “Scumbag!”

Weiner, his mouth full of honey cake, turns around and yells at the man: “Yeah? It takes one to know one, jackass.”

Weiner, who quit Congress in 2011 after a sexting scandal, and the man then confront each other inside the bakery as onlookers take photos.

“You did disgusting things … you have the nerve to even walk around in public,” the man tells Weiner.

“Oh, yeah? And you’re a perfect person? You’re my judge?” Weiner responds. “What rabbi taught you that?”

In another video, released by the Weiner camp later Wednesday, the man can be heard saying “married to an Arab,” presumably a reference to Weiner’s Muslim wife, Huma Abedin, a longtime aide to former U.S. Secretary of State Hillary Rodham Clinton.

Weiner, once a front-runner among the Democratic candidates for mayor, was in the neighborhood greeting voters ahead of the Sept. 10 primary. Polls show Weiner is now a distant fourth among the Democratic candidates.