Djokovic has already qualified for the ATP World Tour finals
Novak Djokovic beat Roger Federer in his own backyard to win the Swiss Indoors final 6-4 4-6 6-2 in Basle.
Federer was bidding to win the event for a fourth-successive year, but fell away in the decider as Djokovic won his fourth title of the year.
The Serb took a tight first set before Federer recovered from a break to level, but the Swiss paid for failing to take chances in the third set.
Djokovic, 22, said: "I played by far my best match. It came at the right time."
The victory over world number one Federer was Djokovic's third in five meetings this year and his 71st victory in total this year - the most on the tour.
Federer, who was once a ball boy at the tournament, was returning after a six-week break following his US Open final loss to Juan Martin del Potro.
The 28-year-old had not previously dropped a set or lost a service game in Basle, but had his serve broken four times on his way to his third final defeat of the year.
The match featured an extraordinary 10th game in the first set where Federer saved six set points and Djokovic five break points before the Serbian wrapped up the set at the seventh attempt.
Djokovic broke Federer's serve in the second but was soon on the back-foot as the Swiss broke back in the fourth with an exquisite drop shot from the baseline.
He repeated the trick to wrap up the second set, helped by a double fault from Djokovic.
But Federer lost serve twice in a row at the start of the third set and frittered away his last chance when he squandered three break points in succession in the sixth game.
Djokovic finished off the match at the first attempt when Federer sent an attempted drive high into the air.
Reflecting on only his third defeat since May, Federer said: "It's disappointing to lose at home in the finals, no doubt.
"I thought I missed plenty of opportunities. I'm not looking for excuses. He played tough and he played well when he had to, and saved a ton of break points that were crucial."