Juan Martin del Potro held his nerve in a final-set tie-break to beat a dogged Roger Federer 6-4 6-7 7-6 (7-3) in the final of the Swiss Indoors in Basle.
The Argentine, 24, outplayed the world number one in the opening set, but Federer, seeking a sixth title in his home event, hit back in the second.
Del Potro saw off four break points in the decider before taking control in the tie-break to clinch victory.
"This is a great win for me, a dream," said Del Potro.
"It's an honour to be on the court with Roger, who is the greatest of all time. It's great to share this moment with him."
Federer, who announced after the final that he would not defend his Paris Masters title next week, told his opponent on court: "You deserved it. You had a couple of tough losses against me this year and I'm really happy for you."
Federer at home
- This was Federer's ninth final in his home tournament, but he failed to add to his victories of 2006, 2007, 2008, 2010 & 2011
- Federer was looking to capture his 77th title, which would have drawn him level at number three in the all-time list with John McEnroe
- Federer has won 875 matches during his career (also level with McEnroe)
In the pair's first meeting since the Swiss beat Del Potro 19-17 in the third set of August's
epic Olympic semi-final at Wimbledon,
it was the Argentine who got off to the better start.
The world number eight, who came back from a wrist injury to win in Austria the previous week, converted his first break point in the fifth game, using his 6ft 6in frame to patiently pound away from the baseline while waiting for a mistake from the Swiss.
Opportunities for Federer to respond were rare, with the 31-year-old only winning five points on big-hitting Del Potro's serve in an opening set lasting only 34 minutes.
The second was much more keenly contested, although Federer again struggled to find any kind of fluency.
The Swiss could not convert his first break point of the match, in the second game, when Del Potro dug himself out of a hole with a powerful forehand before all but dashing Federer's hopes of a break with a wonderful down-the-line winner.
The defending champion survived three deuces in game five to remain on serve at 3-2 and, in his next service game, conjured up successive aces when questioned at 30-30.
Little drama followed until the 11th game when a stunning forehand cross-court passing shot from Del Potro created the 2009 US Open winner's first break point of the second set.
World Tour Finals
Two of the eight places at the year-end World Tour Finals, which begin on 5 November at London's O2 Arena, remain up for grabs.
The final qualifying event, the Paris Masters, starts on Monday.
Both Federer and Del Potro, who qualified by reaching the quarter-finals in Basle, are assured of their places.
Federer responded immediately with a gorgeous winner of his own to recover to deuce before seeing out the game to lead 6-5.
The local favourite struck first in the tie-break, going a mini-break up at 2-1 when Del Potro netted, and served out to take the second set in 64 minutes.
In the decider, Federer could not take advantage of three break points in the third game, and spurned another opportunity in the seventh.
Serving to take the match into a final-set tie-break, Federer - who had won 13 of their 15 previous meetings - was under pressure at 15-30 but rained down a hat-trick of aces.
However, it only postponed the inevitable, and Del Potro converted the first of three championship points in the tie-break.
dedicated his Valencia Open triumph to his friend and former world number one Juan Carlos Ferrero.
Ferrer climbed up into the stands after beating unseeded Ukrainian Alexandr Dolgopolov 6-1 3-6 6-4 to embrace his fellow Spaniard, who retired from tennis earlier in the tournament.
"It was extra special because Juan Carlos has retired and I wanted to dedicate the title to him," he said.
The Spanish world number five has now won six tournaments this year.