HE was trying to bust a move but ended up busting a bullet.

An off-duty US FBI agent dropped his gun ​doing a backflip ​on the dance floor of a Denver bar — then accidentally shot a fellow reveller while scrambling to pick up the piece, according to a report.

According to the New York Post, the unidentified agent was dancing up a storm at the Mile High Spirits bar around 12:45am (2.45pm) on Sunday when he pull​ed off a backflip, video obtained by ABC 7-Denver shows.

As the limber agent landed the flip, his gun went flying out of his holster onto the floor, the clip shows.

The agent pounced after the weapon, but while picking it up accidentally squeezed off a single round.

The shot struck a male onlooker in the lower leg, as the agent tucked the gun into his pants, threw up his hands, and walked out of frame, the video shows.

The victim was treated at an area hospital for a non-life-threatening injury, according to ABC — 7 Denver.

The agent was taken to Denver Police Headquarters, and eventually released to an FBI handler, the network reported.

The incident remains under investigation.