Facing the supremely popular eight-time champion on Centre Court, Djokovic never truly showed his best form but still had enough energy and skill to triumph 7-6 (7-5) 1-6 7-6 (7-4) 4-6 13-12 (7-3) in a marathon contest.
The world No.1 was fortunate to win the opener and then collapsed completely in the second, but he was typically resilient in edging another tie-break in the third set to lead 2-1 without creating a single break point.
A third Wimbledon final victory over Federer was secured despite again crumbling in the fourth as Djokovic was forced to stave off two championship points in the decider.
With the set tied at 12-12, an historic first final-set tie-break was required, and Djokovic got the job done.
Federer, who claimed "the stars are aligned" after beating Rafael Nadal in the last four, had been bidding to become the oldest ever grand slam singles champion but never led a tireless opponent, his errors at crucial moments proving costly.
Djokovic has now won 33 of his past 34 grand slam matches and four of the past five such singles titles, taking his career tally to 16 major crowns.
In their first grand slam meeting in three and a half years, Djokovic struggled with his serve early on — fortunate to see Federer's ferocious forehand squander an opportunity — and could not get his return game going either.
But the No.1 seed escaped from a tricky opener with the lead, reaching a tie-break where Federer's sloppiness gifted him four straight points.
Rather than seize the initiative by kicking on in the second, though, Djokovic swiftly fell two breaks behind, an awkward slip to concede the first break point setting the tone.
A sensational backhand slice set Federer en route to another break to take an improbably straightforward set, although Djokovic dug in at the start of the third.
Federer stayed patient but was taken to another tie-break and his backhand let him down. A messy effort led to an immediate mini-break, another after as he shot into the net.
Djokovic protected that advantage and quickly went after a killer blow in the fourth, but it was Federer, backed by a partisan crowd, who led when a pivotal point saw the Serbian narrowly miss the baseline, teeing up the break.
There was another break, too, before Djokovic belatedly brought his trademark return, losing a 35-stroke rally in his first opening on the Federer serve of the entire match — close to three hours in — but taking the next opportunity.
It was not enough to prevent a decider and the pendulum continued to swing back and forth.
Djokovic fizzed a backhand past Federer at the net for the crucial lead, yet he could not cling on in the next game, a double-fault letting the veteran back in.
Although a sublime stretching Djokovic volley kept Federer from another break point, the veteran finally led for the first time at 8-7 when he whipped a forehand through the defence.
Federer had two shots at championship point in a carnival atmosphere but was reeled back in and Djokovic was the man left standing at the end of a final tie-break, his power somehow persisting as the Swiss mishit a forehand to lose after four hours and 57 minutes.
Novak Djokovic  bt Roger Federer  7-6 (7-5) 1-6 7-6 (7-4) 4-6 13-12 (7-3)
Djokovic – 54/52
Federer - 94/61
Djokovic – 10/9
Federer - 25/6
BREAK POINTS WON
Djokovic – 3/8
Federer - 7/13
FIRST SERVE PERCENTAGE
Djokovic – 62
Federer - 63
PERCENTAGE OF POINTS WON ON FIRST/SECOND SERVE
Djokovic – 74/47
Federer - 79/52
Djokovic – 203
Federer - 218