A longtime criminal was illegally possessing a gun in his pants that went off during a police pat-down in St. Paul and was shot in the leg, according to felony charges.

Peang Lee, 31, was charged Friday in Ramsey County District Court with unlawfully possessing a firearm because of his felony criminal record. Lee remains jailed in lieu of $50,000 bail.

The criminal complaint emphasized that “at no time did officers pull their firearms on Lee” during the encounter early Friday.

“Lee’s gunshot wound appears to have come from the gun that was in his pants pocket,” the charges continued.

Lee’s criminal history includes convictions for domestic assault, third-degree assault, being a felon in possession of a gun and providing alcohol to a juvenile resulting in death.

According to the criminal complaint and police:

The incident occurred about 1:15 a.m. Friday, when officers patrolling in the 1100 block of York Avenue saw Lee and another person acting suspiciously near a gate to a cabinet business, police said.

Lee gave police a fake name and date of birth before he was detained, handcuffed and patted down by an officer for any troubling items. A knife fell to the ground as the search continued.

An officer soon said “Gun” and apparently pushed Lee against a “right fender of a squad car for leverage.” That’s when the gun went off and shot Lee in the leg.

Fire Department medics were called while officers rendered aid. Medics transported Lee to Regions Hospital, where he was treated for his wound and expected to survive.

The Minnesota Bureau of Criminal Apprehension is investigating the incident. Three officers at the scene will be put on administrative leave, which is standard procedure.