The man, who is understood to be a Polish national, had spent the afternoon loitering on the Spanish side of the frontier after being turned away by UK immigration because he had no passport.
But when he saw a Guardia Civil patrol car had been left unattended in the car park, and with the keys still in the ignition, he thought he had found the perfect way to sneak across.
CCTV footage shows that after driving straight past guards on the Spanish side of the frontier he was immediately stopped by authorities in the British Overseas Territory.
“We've been told that the Guardia Civil are obviously very embarrassed,” a source close to the investigation in Gibraltar told The Local.
“The question is not only why was a car left unattended with the keys in the ignition, but why wasn’t he stopped on the Spanish side of the border?”
Gibraltar police handed the man over to the Spanish and he is expected to appear before a judge in La Linea on Wednesday.
Spain still has sovereignty claims over Gibraltar, which was ceded to the British under the 1713 treaty of Utrecht, and tensions persist over Guardia Civil patrol boats entering its territorial waters around the Rock.
“It is inconceivable to think that a Guardia Civil patrol car could enter Gibraltar without being stopped,” said the government source.