He was trying to bust a move but ended up busting a cap.

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

The unidentified G-man was dancing up a storm at the Mile High Spirits bar around 12:45 a.m. Saturday, when he pull​ed off a backflip, video obtained by ABC 7-Denver shows.

As the limber lawman 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.