© PA Photos
Defending champion Federer stormed into a 3-0 lead with an early break that set the tone for a pulsating match that swung back and forth.
In two consecutive Djokovic service games, Federer forced the Serbian to deuce but both times the Australian Open holder survived, and a break in between levelled the scores at 3-3.
The pair then traded games before Djokovic claimed a third break of serve to move close to a one-set lead, but the Swiss maestro refused to surrender and broke back to earn parity once again.
After over an hour of action, the opening set went to a tiebreak, which Djokovic won courtesy of a brilliant flat forehand winner.
More breaks were to follow in a second set that matched the high standard and drama of the first.
During the opening game, Federer broke at the fourth attempt and produced a blistering ace down the middle to prevent Djokovic breaking back in game eight.
A pair of unforced errors then saw the Wimbledon champion waste two set points, which Djokovic capitalised on by recording consecutive breaks that secured him the title.
It is the Serbian's second ATP World Tour finals crown, adding to his previous win back in 2008.