Gioacchino Gammino, a convicted murderer listed among Italy’s most wanted gangsters, was pictured by Google's Street View car as he talked outside a green grocer's in the Spanish town of Galapagar.
The police had believed the Sicilian mafia fugitive was in the country but had been unable to locate him.
Investigators said the Google Street View shot outside El Huerto de Manu, or Manu's Garden, was instrumental in pinning down the exact location of the 61-year-old, who had been living in Spain under the name Manuel.
"How did you find me? I haven't even called my family for 10 years," Gammino is reported to have asked officers when taken into custody. He was arrested on December 17.
A member of a Sicilian mafia group known as Stidda - said to be rivals with the well-known Cosa Nostra mafia - Gammino was a high ranking boss and a drug dealer.
He was jailed for life after his involvement in a fatal shooting in 1989, but managed to escape from a prison in Rome in 2002 while a film was being made there.
Gammino then became a fugitive, cutting ties with his native Italy, although police continued hunting him for decades after his disappearance.
A series of clues eventually led authorities to the image of two men chatting outside a fruit and vegetable shop grocery store in Galpagar, a small town near Madrid.
Despite the image being pixelated, police thought one of the men bore a striking resemblance to Gammino.
His identity was only confirmed when investigators came across a listing for Manu's Kitchen, a nearby restaurant, having googled other businesses in the local area.
A chef called Manuel, who police realised was Gammino, was pictured next to the restaurant's pizza oven, Italian newspaper La Repubblica reported.
He was said to have been identified by a distinctive scar on the left side of his chin.
Gammino is now in custody in Spain and Italian police aim to bring him back to Italy by the end of February.