The Serbian top seed ended his run of three consecutive major final defeats to edge seven-time champion Federer 6-7 (7-9) 6-4 7-6 (7-4) 5-7 6-4 in an enthralling encounter at the All England Club.
A stunning contest, likely to go down as one of the competition's greatest showpieces, saw momentum swing between the duo as they duelled for nearly four hours on Centre Court.
Federer had been searching for a record eighth win at the grass-court grand slam and threatened to complete it when he strung together a five-game winning run to win the fourth set, saving championship point in the process.
However, Djokovic, a beaten finalist at the French Open this year as well as the US Open and Wimbledon in 2013, showed he was made of sterner stuff as he kept cool in the decisive fifth to win a seventh major and return to the top of the world rankings.
The pair matched one another for the first 12 games, although Federer was finding it tougher to hold serve than his opponent, seeing his service games go longer than the Serb's.
With neither player giving an inch, Djokovic won the first nine points on his first serve.
Federer took to serve-and-volley tactics to hold Djokovic off on his serve, and despite surrendering a three-point lead in the tie-break, he took advantage of two missed set points from the 27-year-old to edge in front.
Another stunning rally opened the second set, Federer saving two break points, but Djokovic secured the match's first break two games after to seize control.
It was only the second time Federer had dropped serve in the competition and, despite Djokovic calling a physio for a fall earlier in the set, he looked in fine fettle as he held through to restore parity.
Despite Federer saving two break points in the 11th game and taking 83 per cent of points on his first service in the third set, he ultimately came unstuck in the tie-break as a woeful forehand when 4-3 down sailed wide and allowed Djokovic to serve out and lead for the first time in the match.
With the title in sight, Djokovic broke - at the fourth time of asking - for a 3-1 fourth-set lead. Federer broke back immediately thanks to a cross-court return that lifted the roof off Centre Court, but the veteran netted in the next game to return the initiative.
Despite the writing seemingly on the wall for Federer, he dug deep to force Djokovic into serving for the match at 5-3.
Missed shots and a crucial slip at 30-40 put Federer back in the groove, and he reeled off three more games of the highest order to force a decider.
Federer looked in supreme form, serving out his first three service games to love as the energy seemed to sap from Djokovic's legs, as he once again called for the trainer to treat a calf issue.
However, Djokovic rescued break point for a 4-3 lead and then turned the heat up on Federer's serve, the Swiss having to rescue three break points to remain level.
Federer lost all momentum in game nine, smashing an overhead into the net with a clear court ahead of him, and then going 0-30 down when serving to stay in the contest.
Djokovic smelled blood, just nudging a passing shot wide, before forcing Federer long and then into the net to win his first grand slam since the Australian Open last year.