The Argentine who had announced himself back in 2009 when winning the US Open by beating the same opponent, beat his Swiss rival again 6-4,6-7,7-6 in an absorbing contest.
Federer, who was chasing his 6th Indian Wells title, came into the tournament world no.1 having won in Rotterdam and the subsequent withdrawal of Rafael Nadal, had to fend off match point in the second set, before taking it.
The decider then swung the other way round, with Del Potro 2 match points down, before breaking and then taking the title with a comfortable tie break win.
For Del Potro, who has suffered terrible wrist injuries and surgery in the last ten years, he was overjoyed with the win “it’s difficult to describe with words. It’s like a dream, “ he added.
The women’s tournament also threw up a surprise winner in Japan’s Naomi Osaka.
Osaka, at 20 , became the youngest winner in California, since Ana Ivanovic in 2008, as she beat Russian Daria Kasatkina 6-3,6-2.
The unseeded player who had never won a a title at any level on the WTA or junior circuit, came through a tough week to make the final, with notable wins over Grand Slam champion Maria Sharapova and former world no.1 Simona Halep in the semi-finals.
The win will take Osaka to just outside the top 20 in the world rankings and her next match in Miami will be a first clash with Serena Williams.
Both ATP and WTA head this week to the Miami Open.