The Spanish climber attacked ahead of the Angliru on a trick descent with teammate Jarlinson Pantano and held off a power duo from Team Sky, Wout Poels and Chris Froome, to go to the finish line solo after the incredibly tough climb. He approached the finish line with time to salute and sign off on his long career, eventually finishing 17 seconds ahead of Poels.
Contador spoke about his emotions on finishing his career with a win.
"The truth is it has been a very, very special day," said Contador. "I think it’s very difficult to say good bye in a better way than this, in this place, in this event. In the end, it's a full stop at the end of a career in which I have done everything I wanted.
"I think it's been a beautiful Vuelta even though I am not on the podium. But perhaps if I had been in contention for the overall podium I would have ridden in a different way, more conservative, and instead I have ridden the race I have ridden - I look at the photos, and almost every day there are pictures of me alone because I have been on the attack."
The Spanish star saved the host country's blushes with the win, the first on this year's Vuelta by a Spaniard.
"I knew it was going to be a very special day, the road full of people and everyone watching the stage, and I set the goal for myself of winning on the Angliru," said Contador. "This morning I wanted to win, and when I crossed the line, I thought to myself: goal completed."
His attack proved enough to move him up to fourth on the general classification as Wilco Kelderman (Team Sunweb) suffered on the difficult ascent, but he couldn't take enough time to pass Ilnur Zakarin (Katusha-Alpecin) on the General Classification and finished fourth, just off the overall podium.
"In the end, we couldn't take the podium, but this is not what's important," said Contador. "What's important is to take the victory of the stage and finish with this result for the rest of my life."
"I have been able to enjoy the affection of all the people who say thank you to me. It's been a remarkable month, unforgettable," ended Contador. "I think in the future it'll be remembered that in my last day of competition, I finished it with a win."
With Froome having all but secured the red jersey on the eve of the final stage at Madrid, he will be able to enjoy the final stage in the knowledge that he will complete the rare Tour-Vuelta double for the first time since 1978. He is also set to become the first British winner of La Vuelta with the final podium also comprising Vincenzo Nibali (Bahrain-Merida) and Zakarin.
He will also complete a near clean sweep of the jerseys, having won the overall, general and combined classifications over the three weeks of competition, with only the mountains jersey, won by Davide Villella (Cannondale-Drapac) eluding him.