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 tense 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.
"This is the tournament I always dreamed of winning. This is the best tournament in the world, the most valuable one. The first tennis match I ever saw when I was five years old was Wimbledon and it's stuck in my mind, so to be able to compete on such a high level I'm so grateful to have this opportunity and hold this trophy."
The victory propels Djokovic back to number one in the world, while his seventh major title draws him level with John McEnroe and Mats Wilander in joint eighth place on the all-time winners' list.
For Federer it was a crushing defeat, yet he was magnanimous and even slightly disbelieving of his own resolve having forced a decider after looking down and out at 2-5 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 having reached his ninth final.
"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."
From the get-go this was tennis of the highest calibre with the drama reaching a crescendo as early as the first set as both players' impregnable serves led to a tiebreak that ebbed and flowed.
Federer raced into an early 3-0 lead but was then pegged back and saved two set points before edging it 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 and full of Balkan fire 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 looked largely unhindered, taking the set and levelling the match with a dynamic forehand smash.
The third set provided both players with the chance to flex their serving muscles and a tiebreak was again required to separate the duelling protagonists, with Djokovic coming out on top this time.
The Serb looked to have a hand on the trophy when he broke for a 3-1 lead in the fourth set, but that proved to be the start of an extraordinary series of games where both players took it in turns to take apart the other's serve.
Djokovic served for the match at 5-3 with the Centre Court crowd willing Federer to find a route back into the clash. He duly obliged, breaking again to reduce the deficit to 5-4 before once more 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 the Serb, breaking again and holding for the set as Centre Court rose in a chorus of "Roger, Roger".
Weary legs did not diminish the quality of tennis on show in the decider 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 Djokovic, who accepted the acclaim of an emphatically appreciative crowd when Federer netted a backhand.