The Serb defeated Federer 3-6, 6-3, 7-6 (7/3) to add a third title in the California desert to those he captured in 2008 and 2011.
"I'm just very happy and thrilled to be able to win the first title in this season," Djokovic said.
"I played, three, four matches in three sets, a couple of matches had to come from a set down," he said.
"Mentally this definitely helps my confidence."
Having gained an early break for a 2-1 lead in the third, Djokovic served for the match at 5-4 but was broken.
From there they went to a tiebreaker that Djokovic dominated.
"You always have to dig deep against Roger," said Djokovic, who put every first serve in play in that ninth game and still dropped his serve.
"When I served for the match, he played a fantastic game," he said.
"I couldn't do much about it — I managed to regroup and get into the tiebreak.
"That was absolutely great for me, I mean, from the first to the last point."
Federer sent a backhand long on the first point of the breaker, and Djokovic seized a quick 3-0 lead with an overhead smash off a lacklustre Federer lob and another errant backhand from the Swiss.
"I think I played a good game to break back," Federer said.
"Got the first serve returns back, and then played well from the baseline."
He said playing into the wind likely made it harder for Djokovic to serve it out, but then the Serb had the wind with him for the first six points of the tiebreaker.
"He took advantage of that," Federer said.
"So it was an interesting end to the match, no doubt . . . I might have made a few too many errors when it really mattered."
Federer saved one match point with an ace, but Djokovic ended it on his first opportunity on his own serve when a Federer backhand found the net.
A break of Djokovic's first service game in the match for a 2-0 lead was the only opening Federer needed to take the first set in 31 minutes.
He put 74 percent of his first serves in play and didn't face a break point.
Tightly contested second set
The second set was tightly contested, and it wasn't until the eighth game that Djokovic mustered the first break point of the set.
Federer saved it with a service winner, but a mishit forehand on the next point cost him the break and Djokovic confidently served out the set.
"It was a very even match," said Djokovic, who denied Federer an unprecedented fifth Indian Wells title to go with those he won in 2004, 2005, 2006 and 2012.
"As I said before the match, very few points will decide a winner, and that's what happened."
The 32-year-old Federer was trying to become the oldest player to win a Masters title since a 34-year-old Andre Agassi won at Cincinnati 2004.
Instead, Djokovic claimed the 17th elite Masters title of his career.
In the 33rd career meeting between the tennis heavyweights, Djokovic avenged a loss to 17-time Grand Slam champion Federer in the semi-finals last month at Dubai, where Federer went on to win his first title in nine months.
The Swiss great will rise from eighth to fifth in the world on the strength of reaching the final here.