The Grand Slam record-holder from Switzerland beat the world number one from Serbia 6-4, 7-5 in a colourful success which took Federer's title haul here equal to those of Halle and Wimbledon. It also put him 20-17 up against Djokovic
Federer served superbly, his 12 aces taking his career total past 9,000, something only three other players have done since 1991.
Even more noticable was his risk-taking, the frequency with which he approached the net, and the commitment with which he attacked his ground strokes.
The victory was a fine riposte to those who said after his third round loss to Andreas Seppi in the Australian Open that his good days were now behind him.
"People are often saying how old I am - but who knows how many years I have left. I can still play with the best," the 33-year-old said challengingly.
It required only one break of serve in the first set, in the eighth game, to give Federer the thrust he needed to close out the first set.
And one break was enough in the second, coming in the eleventh game.
Djokovic nevertheless came very close to vital breakthroughs when he had Federer at 15-40 in the third game of the first set, and again in the eighth and tenth games of the second set. The last two were both set points, and both were saved by aces.
"I definitely won the big points tonight," said Federer.
"I am very happy with this - otherwise I don't think I would be here giving this interview.
"It's very special to be part of this match. We have played many, many times, and this seventh title does mean a lot. I will always come back here every single year."
Djokovic, who was thus denied the 50th title of his career and the opportunity to overtake the 49 won by his coach Boris Becker, may reflect on the seven chances to break serve altogether which got away.
The first offered Djokovic perhaps his best chance when he pushed Federer back from the net with a decent lob, only for the maestro to produce a nerveless, powerful and accurate smash.
The second was abruptly truncated with a fine first serve, and this seemed to inspire Federer.
The two break points at 3-4 in the second set were similarly dispatched with an ace and a first service winner, and the two at 4-5 with even more rapid aces.
Djokovic had a break point in the last game of the match too, but that was to break back.
Federer saved that with the greatest difficulty of any of them, with a smash from a deep high lob which he could easily have missed.
But Federer was relaxed, pressure-free, and enormously buoyed by the noise of his many supporters here.
"Better than losing in the first round of the doubles," he said, recalling his brief exploits with Swiss compatriot Michael Lammer.
"You work hard and travel a lot, and make sacrifices and hope it pays off in big matches. It's been a wonderful week. After this you can't wait for the next tournament to start."
Djokovic often played very well, and claimed he could not have done more. He had to be pleased with what he had done, he reckoned, even if it was the first time that he had lost in his five finals here.
But Djokovic did have one last laugh.
"How come you had seven break points and he had two - and you lost?" he was asked on court afterwards.
His answer caused the stadium to erupt. "I think I will get the same question a little later from Boris," he said.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ