An off-duty FBI agent accidentally shot a bystander in the leg when his gun fell from its holster as he cavorted on the dance-floor of a bar in Denver, Colorado, police said.
Video widely shared on Twitter shows the agent strutting his stuff and then performing a backflip.
The gun falls to the floor and, as the agent goes to grab it, fires a shot.
The fellow customer hit by the bullet was taken to hospital with a non-life-threatening injury.
It is unclear if the agent, who has not been named, will face charges or disciplinary action.
The video shows that his wild moves on the dance-floor had attracted an appreciative crowd at the Mile High Spirits and Distillery bar on Saturday night.
But the mood quickly changed when the gun went off. As shocked patrons look on, the agent retrieves his weapon, holds up his hands and leaves the floor.
Denver Police Department said the agent "was dancing at a nightclub when his firearm became dislodged from its waistband holster and fell on to the floor. When the agent retrieved his handgun an unintended discharge occurred".
The statement added: "The victim was transported to the hospital with a good prognosis."
Police spokeswoman Marika Putnam said the agent was taken to a police station and later released to an FBI supervisor.
The Denver District Attorney's office said the incident remained under investigation.