The win means that the Serb, 28, was able to overhaul the likes of Jimmy Connors, Andre Agassi and Ivan Lendl in the all-time list of major winners.
Federer, 33, was inline of becoming the first man to win Wimbledon eight times but failed at the last hurdle.
The Swiss won an entertaining second set tie-break but Djokovic came through to win in two hours and 56 minutes.
“I have to say it’s a big challenge playing against Roger,” he said. “A lot of players of my generation have looked up to him and followed his lead.
“He makes you push your limits, work hard and win every single point.”
Federer said: “I had my chances in the first set. I got lucky to win the second, had chances in the third.
“But he was better on the bigger points. He was rock solid, I didn’t play badly myself. That’s how it goes.”