In one of the most dramatic matches the All England Club has ever witnessed, Djokovic defied a crowd screaming for his opponent by becoming the first player to win a singles match on a deciding tie-break.
Djokovic had saved two match points when Federer served for victory at 8-7 in the deciding set and went on to take it 7-6 (5) 1-6 7-6 (4) 4-6 13-12 (3) after four hours and 57 minutes.
Federer had hoped to follow up his emotional semi-final victory over Rafael Nadal by completing the double over his other great rival for the first time at a grand slam and fought back well having twice been a set down but this will be one of his most painful losses.
— Wimbledon (@Wimbledon) July 14, 2019
Djokovic has now won four out of the last five major tournaments, taking his overall tally to 16 and making Federer's record of 20 seem ever more within reach.
The historical importance was a key theme of this final, with 37-year-old Federer staring at perhaps his last chance to put further distance between himself and his younger rivals.
Nadal is only two adrift and showing no sign of letting his iron grip on the French Open slip, while Djokovic has been open about the fact he is playing for history.
That perhaps played a part in this strange match, which rarely hit the heights in terms of sustained quality yet had enough plot twists for a feature-length thriller, even before its extraordinary deciding set.
Federer was the better player for all of the first four sets, with Djokovic's game strangely off colour apart from his serve, but played two poor tie-breaks either side of a set that his opponent barely turned up for.
The fifth set was scarcely describable, finally ending in the 25th game when Federer, who had been chasing a ninth title, framed a forehand into the crowd.
The tie-break at 12-12 was introduced following last year's epic semi-final between John Isner and Kevin Anderson yet had not been used in a singles match until this contest.
After 47 previous matches, 25 of them won by Djokovic, there were no secrets between these two and the first set was fascinating to watch as Federer sought to take his opponent out of his baseline comfort zone.
Federer, who had not beaten his rival since 2015, used the short backhand slice to pull Djokovic forward, mixed up the pace and threw in a number of drop shots.
He had a break point in the third game, and was two points from the set at 4-5, 0-30 but could not take either chance.
Errors then cost Federer after he turned a 1-3 deficit in the tie-break into a 5-3 lead, a mistimed backhand dropping into the tramlines on Djokovic's first set point.
It must have been a painful set to lose for the Swiss but in double-quick time he was level at one-set all after an uncharacteristic mental lapse from his opponent.
A slip behind the baseline in the opening game perhaps unsettled Djokovic, who appeared to decide not to expend any unnecessary energy after going two breaks behind.
The most unexpected factor was how poorly Djokovic was returning but he somehow stayed with Federer through the third set.
He created one set point in the 10th game with a glorious half-volley but Djokovic's serve – the one part of his game that was working well – bailed him out.
The Serbian was beginning to look very frustrated but he forced another tie-break and again it was Federer who unexpectedly crumbled.
Given Federer had never won a five-set match against Djokovic, that left him with a serious mountain to climb, but, just when it seemed he might finally be taking control, his level dropped again and Federer surged into a 5-2 lead.
Djokovic finally forced a break point, and converted it, to give himself a chance of rescuing the situation but Federer served out the set at the second opportunity, the partisan crowd roaring their approval.
History still said Djokovic was the favourite and, after Federer saved three break points in the third game of the decider, he made the breakthrough to lead 4-2.
But he could not cement it and on the match went, the tension growing with each point.
Djokovic was in trouble at 5-5, 15-30 but produced a diving volley winner, then Federer was two points from defeat three times in the next game but held on.
Federer, who turns 38 next month, looked to have made the crucial breakthrough when a forehand pass gave him an 8-7 lead and the chance to serve for the match.
His serve carried him to 40-15 but he netted a routine forehand on the first chance and was then passed by Djokovic, who went on to break back.
The world number one saved two more break points at 11-11 and that proved to be Federer's final chance as Djokovic surged ahead in the tie-break and this time there was no way back.