Italian and Spanish police swooped on Salvatore D'Avino, one of Italy's most wanted fugitives, as he was filling his car with petrol in a town on the Costa del Sol.
D'Avino, 39, alleged to be a member of the Naples-based Camorra mafia, had been on the run for four years.
Italian police said he had been living under an assumed identity in Morocco.
A few days ago he travelled to Spain by boat with his Moroccan girlfriend, who is pregnant.
The young woman, who has not been named, wanted to show off photographs from their holiday and uploaded a number of pictures to her Facebook page.
But the images enabled Italian police to pin-point the whereabouts of D'Avino, who was on a list of Italy's 100 most wanted alleged mafia gangsters, and they arrested him on Tuesday near Marbella.
D'Avino is alleged to be a member of one of the drug-dealing clans that make up the Camorra, the Neapolitan cousin of Sicily's better known Cosa Nostra.
He was wanted on charges of drug trafficking and mafia association and if convicted faces up to 20 years in prison.
Facebook proved to be the undoing of another alleged mafia mobster last year, when police located him by tracking the internet key he used to log onto the internet.
Pasquale Manfredi, 33, who called himself "Scarface" in tribute to the gangster film starring Al Pacino, was wanted for killing a rival godfather with a shoulder-fired rocket launcher in 2004.