The Serb, who has now won seven grand slam titles, denied Federer the opportunity to win a record eighth All England Club trophy but was pushed all the way by the Swiss who faced a match point in the fourth set before forcing a decider.
Djokovic eventually wrapped up the contest that will go down as one of the greatest Wimbledon finals in three hours and 56 minutes, falling to the ground in celebration before climbing to the players' box to greet his camp with an emotional embrace.
"I don't know how I managed to do it," said a teary Djokovic, who had lost his last three grand slam finals.
"I want to dedicate this win to a few people, first of all to my future wife and our future baby. I am going to become a father soon and I am still preparing for that.
"To my family and my team for sacrifice a lot of their lives to allow me to live the dream and to my first coach Jelena Gencic, who taught me everything about playing tennis and how to behave. Unfortunately she passed away last year but this is for her."
Federer was magnanimous in defeat and even slightly disbelieving of his own resolve having forced a decider after looking down and out at 5-2 down in the fourth set.
"It was a great final. I can't believe I made it to five, it wasn't looking good for a while," he said.
"Going into a match with Novak, you know it's going to be tough. I can only say congratulations to him. It was an amazing match and an amazing tournament. It's well-deserved."
The Djokovic serve had seemed impregnable in the early games of the match. He held three times for the loss of a single point, while he was also able to apply gentle pressure on his opponent with some stinging returns.
The Stefan Edberg effect on Federer's game seemed to be in evidence as the Swiss made frequent forays to the net, with limited success, but both players held their nerve to take it to the tiebreak.
Federer, chasing a record eighth title, raced into an early 3-0 lead but was then pegged back and saved two set points before coming out on 9-7 when Djokovic netted a backhand after 51 minutes of scintillating play.
If Djokovic was simmering with a sense of injustice at losing a set in which he lost only four points on his first serve, he hid it well and came out energised in the second.
Federer was forced to save two break points in his opening service game and another in his next, but Djokovic made no mistake at the fourth time of asking, claiming the first break of the match for a 2-1 lead with a searing backhand pass.
The Serb called the trainer on court to treat an ankle injury, but stayed largely untroubled until he tried to serve out the second set at 5-4.
At 30-30, the Serb hit a forehand wide to hand Federer his first break point of the match, but swiftly regained his concentration to bring up set point with an ace and saw it out with a forehand smash.
In the third set both players flexed their serving muscles with the ace count mounting and neither facing a break point until the 11th game when Djokovic began to turn the screw once more.
The Serb ground out two break points but Federer again dug in, saving both with some precision serving to hold after a series of deuces.
It proved a brief reprieve however, as Djokovic came out firing in the tiebreak, bringing up a set point at 6-4 with a big forehand winner and getting over the line when Federer hit a backhand slice wide.
Djokovic looked to have a hand on the trophy when he pumped his clenched fist in celebration having broken in the fourth game of the fourth set for a 3-1 lead.
It proved to be the start of an extraordinary series of games, however, where both players took in turns to take apart the other's serve.
Federer broke straight back before again handing the momentum to the Serb, who opened a 5-2 lead and served for the match at 5-3.
The Centre Court crowd were willing Federer to find a route back into the clash and he duly obliged, breaking again to reduce the deficit to 5-4 before again finding himself under pressure to survive.
He netted a backhand to give Djokovic a matchpoint but served his way out of trouble and then set about putting the pressure back on Djokovic, breaking again and holding as Centre Court rose in a chorus of "Roger, Roger".
Weary legs did not diminish the quality of tennis on show in the fifth set as both players tussled for an advantage in the early evening sunshine.
Federer saved three break points in the eighth game as Djokovic and his famed resolve sought to take charge once more. The 32-year-old's seeping reserves could not hold out for long.
Serving to stay in the match at 4-5, Federer fell to 15-30, and then sent a forehand long to bring up another match point.
This time, there was no stopping the Serb as Federer netted a backhand to leave Djokovic to accept the acclaim of an emphatically appreciative crowd.
- Sports & Recreation