A St. Petersurg man who was running from the police tried to carjack a vehicle.

Inside was an undercover cop.

Arrest reports detail how police say the incident unfolded near the intersection of Gulfport Boulevard and 49th Street S at about 8:45 p.m. Wednesday night.

When it was over, Donald Steven Dugray, 20, was arrested on multiple charges, including attempted carjacking.

Gulfport police tried to stop Dugray on his bicycle that night for a light violation, but he took off and crashed into a sergeant’s cruiser. When Dugray hit the ground, a gun fell out of his waist band, reports state.

He picked up the gun and ran away from police, then tossed the gun onto the roof of a nearby diner. Officers later recovered the revolver, which had five rounds in it, reports state.

As Dugray was running from police, an undercover officer was moving into the area to help. As the officer opened the door of his vehicle, Dugray grabbed it and leaned into it “as if he was attempting to get into the vehicle and pull (the officer) out,” an arrest report states.

The officer hit Dugray with the door and pulled his gun on him. Other officers then caught up to Dugray and took him into custody, but not before he violently resisted arrest, reports state.

In addition to attempted carjacking, Dugray was arrested on charges of carrying a concealed firearm, resisting arrest, fleeing police and tampering with evidence. Bail was initially set at $135,500 and Dugray was being held at the Pinellas County jail Monday.

He also faces charges of violating his probation on charges of burglary and grand theft out of Brevard County.

An assistant public defender has entered a plea of not guilty on his behalf.