A 25-year-old man is critical condition after allegedly jumping into the back of an undercover squad car and attempting to steal a sergeant's gun.

Police say the unidentified suspect crawled into the back of an unmarked patrol car as it stood idling at a light on Avenue D and Nostrand Avenue around 12:45 a.m. A struggle ensued between the man and the vehicle's other occupants—a sergeant and an officer—resulting in the weapon being fired in the car. Though details of what exactly transpired in the car remain murky, the Daily News reports the man leaped out of the car wielding the sergeant's gun, at which point officers stationed nearby opened fire.

A food cart worker down the street said he heard a steady stream of gunfire totaling around 20 shots. "I heard 'Pop, pop, pop!' maybe seven of them," he told the tabloid. "Then a few seconds of silence. And then it started again and again."

The suspect, who was shot in the back and ankle, was taken to Kings County Hospital in critical but stable condition. The cops were all uninjured, though three were treated for tinnitus.

Charges against the suspect are pending.