The 29-year-old from Argentina handed Federer his first match defeat of 2018 and extended his own win streak to 11 matches, including a title run earlier this month at Acapulco.
“I’m still shaking,” Del Potro said. “It’s difficult to describe with words. It’s like a dream.”
Del Potro, nagged by wrist injuries throughout his career, survived three match points before claiming the championship in a third-set tie-breaker, ending a two hour, 42 minute marathon contest.
“I cannot believe I won this tournament, beating Roger in a great final and this level of tennis. We played great tennis today,” Del Potro said.
“I just want to keep winning titles like this if I can.”
Del Potro won the first five points of the deciding tie-breaker then closed it out when Swiss superstar Federer, who had won a career-best 17 straight matches to start the year, smacked a forehand long.
It was an emotional match for both players as each took turns questioning the chair umpire. Del Potro urged him to stop the pro-Federer crowd from making noise on his serve and an irritated Federer also had a couple of lively conversations with the umpire.
“I don’t remember half of it,” said Federer. “I was trying to pump myself up more, get energy for me. It had no effect on the outcome.”
Del Potro was competing in his first Indian Wells final since 2013, when he lost to Spaniard Rafael Nadal.
It was Del Potro’s seventh victory over Federer in 25 career meetings, one of those wins coming in the 2009 US Open final.
“I always play good against him. I won a couple of finals and lost a couple of finals. In the end I was lucky to win. We played great tennis today,” Del Potro said.
World number eight Del Potro is back in the rankings top 10 after dropping to 1,045th before beginning his comeback from three left wrist surgeries in 2016.
“I am excited to see what is next,” he said. “I am still surprising myself and I want to keep surprising the tennis tour,” Del Potro said.
Federer blasted 10 aces but had five double faults and his serve was broken twice.
He said it is going to take a little longer than normal to get over this one.
“It should sting,” Federer said. “The question is how long? It is disappointing talking about a great match like this and losing.
“You move on. There’s no time to dwell over it. I see the positives at the end of the day.”
Federer survived a match point in the second set tiebreaker to force the third.
“It was a lot of chances at either end,” he said. “He should have maybe closed it first in the second set I believe. Even early in the second set I think he had break point chances.
“But I was able to find my game and get out of that game.”
In the 10th game of the third set Federer returned the favour with three match points of his own but Del Potro timed his forehand shots perfectly.
“It was disappointing,” Federer said. “Juan Martin was a bit better at the end. It was maybe a point here or there, maybe a shot, maybe a forehand, maybe a chip.”
Federer, the oldest world number one in ATP history at 36, entered the final having dropped just one set, in a difficult semi-final test from Croatia’s Borna Coric.
Federer’s five Indian Wells titles included last year, when he beat fellow Swiss Stan Wawrinka.