Two police officers spotted the bicycle during an inspection of the shop in the southern city of Malaga and became suspicious because the asking price was so low despite its “exceptional characteristics”, police said in a statement.
They opened an investigation and discovered it matched the description of a bike that was stolen from Australian cyclist Simon Gerrans at the end of the third stage of the Tour of Spain race on August 24, a ride from Mijas to Malaga.
The bicycle had been sold to the shop by a man who lives in Malaga “with a long police record”, along with another one which was also on display.
Police handed the bicycle over to a representative of Gerrans' Australian Orica Greenedge team in Madrid on Sunday.
“We are going to offer a jersey with stripes to the one who stole the Orica Greenedge bike, His final stage is jail,” police joked on their official Twitter account which has 1.8 million followers.
Race leaders are traditionally given a red jersey to wear.
Italy's Fabio Aru is on the verge of sealing his first Grand Tour win after he moved into the lead of the Tour of Spain, or the Vuelta a Espana, on Saturday with just Sunday's parade around Madrid to come.