The Serb emerged tops in a keenly contested game that lasted in five sets 6-7 (7-9) 6-4 7-6 (7-4) 5-7 6-4.
Federer claimed the first set in a tie-breaker and looked on course to win a record eight title at Wimbledon,but Djokovic clawed his way back taking the next two sets of the game.
The 27-year old let a championship point slip through him in the fourth set,giving Federer an opportunity to set up a deciding fifth set.
Djokovic broke Federer in the final set and there was no stopping him as he claimed his seventh Grand Slam win.
"After losing the fourth set it wasn't easy to go on and win the fifth set, I don't know how I did it," Djokovic told BBC Sport.
"This is the best tournament in the world and the one I always wanted to win so to be able to compete at such a high level I am so grateful."
Djokovic with the triumph will now reclaim the number one ranking from Rafael Nadal.