A 23-year-old man was shot in the buttocks by his own pistol in Brooklyn as he ran from two muggers — one of them armed — who demanded his cash, police source said.

The man told cops he threw his phone at the two muggers as they tried to rob him at Winthrop Street and Brooklyn Avenue in East Flatbush around 10 p.m. Monday. He then fled.

As he was running, the gun in his back pocket discharged, hitting him once, the sources said.

The victim was taken to Kings County Hospital by private means. Ballistics were recovered in his pocket, the sources said.