He was implicated in the Operacion Puerto doping case that same year, and removed from the Tour de France roster, before being cleared of wrongdoing by the UCI.
Speaking via a video on Instagram, Contador said: "Hi all, I would like to inform you about two things". It's a decision that I have thought very well and I don't think there is a better farewell than in the home race and in my country.
"I'm sure they will be three wonderful weeks, enjoying all your affection, and I can't wait to get started".
Second only to five-time Tour victor Miguel Indurain in Spanish cycling lore, the 34-year-old Contador has been one of the sport's top riders for the last decade in a contentious career.
Contador is one of the world's most accomplished cyclists and has won all three major European tours, the Tour de France (2007, 2009), the Giro d'Italia (2008, 2015) and the Vuelta a España (2008, 2012, 2014). "Greetings and see you on the road from August 19th".More news: STF fará acrobacia jurídica para manter Aécio Neves nas funções de senador
More news: Melbourne cafe charges men 18 percent premium
More news: Kayleigh McEnany returns to Trump team after leaving CNN
Having initially announced his intention to retire at the end of 2016, his impressive form last season encouraged Contador to continue for 2017 as he switched teams to Trek-Segafredo.
He also won the 2010 edition but in 2012 was stripped of that title after being banned for two years after testing positive for the banned substance clenbuterol at the race.
Speculation mounted that Contador, who was also stripped of the 2011 Giro, would retire following a disappointing showing at last month's Tour de France, where he finished ninth.
But the seven-time Grand Tour victor - who also had two further Grand Tour wins scratched from the record after testing positive for clenbuterol in 2010 - is now keen to bow out in his home country.
"It goes without saying we wish him the very best for his future afterwards!"