The top-ranked Serb recovered from early breaks in both sets and beat Federer 7-6 (6), 7-5 Monday in the championship match at the ATP finals.
Federer broke Djokovic's serve to take a quick 2-0 lead in the first set, and then again to open to the second set, but both times the world's No. 1 player rebounded to get back into the match.
"It's not the first time that Roger starts against me so well," Djokovic said. "I've experienced before his aggressivity, really trying to put his mark on the match. It's what he's done again."
Federer indeed started well, winning the opening nine points and 12 of the first 14 to take a 3-0 lead. He then won the first point of the fourth game, but Djokovic finally held his serve — and soon broke back.
In the ninth game, Djokovic broke again to serve for the set at 5-4, but Federer evened the score and forced the tiebreaker.
"Maybe a bit of regret because I had the lead twice first before him," said Federer, the two-time defending champion. "At the end of the day, that doesn't matter. You have to get over the finish line in the set and then obviously at the match. He was better at that today."
The crowd at the O2 Arena was decidedly in Federer's favour, but they cheered loudly throughout the match as both made spectacular shots — including a match-ending backhand passing winner from Djokovic.
"It's best way to finish the match, I guess, with a passing shot, one of my favourite shots," Djokovic said. "He came in. That was the only space left for me to make a passing shot, and I made it."
The highlight for Federer came in the tiebreaker with Djokovic holding his second set point.
Djokovic hit a forehand drop shot with Federer up at the net. The ball drifted past the second-ranked Swiss, but he chased it down and whacked a forehand winner to even the score at 6-6.
Two points later, however, and Djokovic was the one celebrating, ending the set with a forehand winner on his third set point.
To start the second set, Federer broke Djokovic for the third time and then held all the way to 5-3. A game later and serving for the set, Federer had two set points but he put a forehand wide and a then forehand into the net.
Two more Federer mistakes put Djokovic back on serve and back on track for the title. The Serb closed it out with the backhand passing winner to improve his head-to-head record against Federer to 3-2 this year, and 13-16 overall.
"I shouldn't have been broken as often as I was broken today," said Federer, who lost his serve twice in each set. "But then again, that obviously has something to do with Novak, as well."
Federer finished the match with 30 winners, 11 more than Djokovic. But he also had 42 unforced errors — many of them coming from his often dominant forehand — while Djokovic had only 28.
"Obviously I was going to try to go after my shots and not just hand it to him. That's just how I play tennis," Federer said. "If I have 80 errors and I win the match, I don't care. I really don't."
It was Djokovic's second victory at the year-end tournament for the top eight players in the world. He also won in 2008, when the tournament was in Shanghai.
Federer, who is now 15-3 in Britain this year after winning his seventh Wimbledon title and the Olympic silver medal, had been looking for his record seventh title.
And he came close to winning it.
Both players finished the match winning 58 per cent of their service points and 42 per cent of their return points. Overall, Djokovic only won one more point in the match, getting 96 to Federer's 95.
Djokovic came into the ATP finals knowing he would end up as the No. 1 player in the world for the second straight year. He backed it up with a victory in London.
"It's been a very long year, a very long two years, but very successful two years," said Djokovic, who won the Australian Open at the beginning of this season and won three major titles in 2011.
"I actually feel even more satisfied right now than last year, even though I had an incredible 2011. I feel this year, considering the circumstances that I had to face on and off the court, expectations, all these things, I believe that this year has been even more successful for me."