Juan Martin del Potro denied Roger Federer his hometown Swiss Indoors title for the second straight year, winning the final 7-6 (3), 2-6, 6-4 on Sunday.
The top-seeded Argentine clinched the title when Federer could not return a forcing forehand.
"It's always a pleasure playing against you," del Potro told Federer during the trophy ceremony. "I know you are the hero here and for me a big inspiration, too."
Federer had hoped the raucous support at Basel, where he is a five-time champion, could help revive his difficult season. He's won just one title in the past 14 months.
"I was lifting my level and in the end I wasn't playing too badly," Federer said in German, praising del Potro for "a great tournament again."
The sixth-ranked Swiss edged closer to securing his place in the eight-man lineup at the ATP World Tour Finals in London starting on Nov. 4.
Federer will likely confirm his London place at the Paris Masters next week, where he is seeded fifth and has a second-round match against Kevin Anderson of South Africa or Mikhail Youzhny of Russia.
Del Potro earned his fourth title this season, all on his favored hard-court surface. He also won at Rotterdam in February, Washington D.C. in August and Tokyo this month.
With this loss against fifth-ranked del Potro, Federer has only one victory against a top-10 opponent in 2013. That was back in January, against then-No. 8 Jo-Wilfried Tsonga in the Australian Open quarterfinals, before back injuries helped hamper his season.
The 32-year-old Federer still holds a 13-5 career record against del Potro, but has lost the last three including the 2012 Basel final.
On Sunday, Federer lost the first set despite playing some of his best tennis this week.
After del Potro forced a 5-3 lead with the first break, Federer responded with four straight points on his opponent's serve and shouted in triumph.
Facing two set points in the next game, Federer hit an ace and won a long, slugging rally that brought a yell of delight from the sold-out crowd of 9,200.
Still, del Potro dominated the tiebreaker helped by two net cords in his favor, and clinched the set when Federer sent a forehand wide.
Federer leveled the match with much less drama in the second set, after breaking to take a 2-0 lead with a forehand crosscourt winner.
He broke again to clinch the set, set up by a pinpoint forehand winner, and got a standing ovation as he headed back to his seat.
Federer quickly wasted the advantage of serving first in the decider, despite saving a break point with a leaping backhand overhead winner after del Potro's deft lob. He double-faulted to give del Potro a second opportunity and then hit a forehand long.
Del Potro spurned a good opening to lead 5-2 when he netted a forehand approaching the net after Federer's drop shot sat up invitingly.
Serving for the match, del Potro hit an ace to set up three match points, and converted the second with strong ground strokes to move Federer around the court.
Del Potro improved to 48-13 this season and earned 348,000 euros ($480,000) for the victory.
Federer, now 40-14 in 2013, was playing his first final since winning the low-key grass-court event in June at Halle, Germany.
He remains tied with John McEnroe on 77 career singles titles, third most during the 45-year Open era. Jimmy Connors has 109 titles and Ivan Lendl has 94.