The veteran thwarted four ferocious attacks by Nibali on the misty and steep 12.5-km Alto de L'Angliru ascent and 1-km from the finish he raced away from his rival to cross the line in second place, 26 seconds behind stage winner Kenny Elissonde of France.
"Nibali's attacks make this win much more epic, the fans must have been on the edges of their seats back home," Horner told reporters.
Asked if he needed time to realise he was on the brink of his first Grand Tour victory, Horner replied: "I've had lots of time to think about it, about how much suffering it's taken to get this. What I'm feeling today will last a lifetime".
Riding through tunnel-like lines of cheering fans and dense fog, Nibali briefly dropped Horner as the climb became steeper with 7-km to go.
But the American recovered well to regain contact and counter each of the Italian's moves before punching one arm skywards as he crossed the line.
With the first victory by an American in the Vuelta close to hand, Horner is set to smash the records for the most senior Grand Tour winners.
He is eight years older than Tony Rominger of Switzerland was when he won the race in 1994 and five years older than the Tour de France's most senior winner, Fermin Lambot, who triumphed in his home race in 1922 at the age of 36.
"My son will now be able to say his dad is the oldest ever Grand Tour winner, the only 40-something to have done that," said the American. "He'll be able to enjoy that for the rest of his life."
One week after his team mate and compatriot Alexandre Geniez won the Vuelta's most difficult mountain leg at Peyragudes, the 22-year-old Elissonde's solo breakaway clinched a second notable stage victory in the race for the FDJ.fr squad.
"Getting a victory on my first Grand Tour and on the most difficult climb of the race was not in my pre-race plans," said Elissonde with a grin.
"I didn't even know the gap on the guys chasing me, the support vehicles were stuck in the crowds, but it turned out to be enough."
Stage 20 Results
1. Kenny Elissonde (France / FDJ.fr) 3:55:36"
2. Chris Horner (U.S. / RadioShack) +26"
3. Alejandro Valverde (Spain / Movistar) +54"
4. Vincenzo Nibali (Italy / Astana)
5. Andre Cardoso (Portugal / Caja Rural)
6. Dominik Nerz (Germany / BMC Racing)
7. Jose Mendes (Portugal / NetApp) +1:15"
8. Joaquim Rodriguez (Spain / Katusha) +1:45"
9. Serge Pauwels (Belgium / Omega Pharma - Quick-Step) +1:52"
10. Thibaut Pinot (France / FDJ.fr) +1:59"
1. Chris Horner (U.S. / RadioShack) 81:52:01"
2. Vincenzo Nibali (Italy / Astana) +37"
3. Alejandro Valverde (Spain / Movistar) +1:36"
4. Joaquim Rodriguez (Spain / Katusha) +3:22"
5. Nicolas Roche (Ireland / Saxo - Tinkoff) +7:11"
6. Domenico Pozzovivo (Italy / AG2R) +8:00"
7. Thibaut Pinot (France / FDJ.fr) +8:41"
8. Samuel Sanchez (Spain / Euskaltel) +9:51"
9. Leopold Koenig (Czech Republic / NetApp) +10:11"
10. Daniel Moreno (Spain / Katusha) +13:11"
- Sports & Recreation
- Kenny Elissonde
- Chris Horner
- Alejandro Valverde
- Tour de France
- Vincenzo Nibali