(CNN) --Contador finished safely in the main bunch on the final stage into Madrid won by Danish rider Matti Breschel of the CSC team.
The Spaniard matches French pair Jacques Anquetil and Bernard Hinault, Belgian legend Eddy Merckx and Italian Felice Gimondi as riders who have also won the Tour de France and Giro d'Italia.
Contador, who burst onto the scene with victory at the 2007 Tour de France while riding for the Discovery Channel team, won the Giro d'Italia earlier this season.
He has achieved the feat in the space of 15 months, beating the previous record of 26 months by Hinault.
He was pushed all the way in Spain by his teammate Levi Leipheimer of the United States, who won Saturday's 17.1 kilometer hilly time trial.
It enabled him to close the gap on Contador to 46 seconds, but this was always likely to remain unchanged in Sunday's largely ceremonial stage into the Spanish capital