Djokovic's fourth Indian Wells title not only allowed him to avenge his loss to Federer at the Dubai Duty Free Tennis Championships last month, but also saw him become the 12th player in the Open era to win 50 titles at tour level.
Having not lost a set en route to the final, Djokovic was on track to keep that streak alive when he won the first set 6-3.
The Serb claimed an early break in the second set, going up 2-1, but Federer broke back to remain in the contest, a break which earned him a standing ovation.
The set was forced into a decider and it was Federer, with the support of the crowd helping him on, who took the breaker 7-5 despite Djokovic having lead first 3-1 and then 5-3.
It was the world number one who claimed the early break in the third, but he cut a frustrated figure as Federer broke back and then held his serve to level matters at 2-2.
Having taken his frustrations out on one of his rackets, Djokovic got back in the groove and sprinted through the next four games to take the set 6-2 and with it the match.