Spain's National Police made the shocking discovery when arresting the dealer outside a bar in the north-eastern Spanish city of Huesca.
The local pusher, who told police he felt "safer" with the weapon, was in the process of threatening someone with the handgun when he was arrested.
When checking the serial number on the piece, it was revealed it belonged to a local Civil Guard officer, Spanish news agency EFE reported.
Although the dealer told police the officer had given it to him in return for a copious amount of Class A drug speed, she argued she "hadn't even noticed it had gone missing" as it wasn't her service revolver.
A local judge freed both suspects despite charging the dealer with charges of illegal possession of weapons and the officer as a collaborator in the offence.