Australian Open champion Djokovic squandered a 3-0 lead in the final set as he was broken twice by the towering Argentine before losing a wildly fluctuating contest that lasted two hours and 49 minutes.
Serving for the match, the seventh-seeded Del Potro sealed victory with a 133 mph ace to claim only his third win over the Serb in 11 career meetings, and book a place in Sunday's final against Rafael Nadal. The Spaniard beat Tomas Berdych 6-4 7-5 in the earlier semi-final
The top-seeded Djokovic had not previously lost since his defeat last October to big-serving American Sam Querrey in the second round of the ATP Masters 1000 event in Paris.
"I didn't deserve to win today," Djokovic, 25, said after falling short in his bid to reach the final for a fourth time at Indian Wells, where he won the title in 2008 and 2011.
"You know, whenever I had chances, in the second and third sets, I throw them away with some unforced errors. My movement was poor, and I congratulate to my opponent."
Asked what had turned the tide when he led 3-0 in the final set, Djokovic replied: "His fighting spirit and my lack of concentration. He deserved to win because he was more composed in the important moments and he played the right shots.
"He stepped into the court, where, on the other side, me, I made a lot of unforced errors and was at back of the court too passive.
"I didn't use my backhand along the line as I usually do. It's one of my best shots. Today I just wasn't there. It's okay, you know. It happens. It's sport, and I just didn't make it this time."
Djokovic had been a perfect 17-0 for the season after winning his sixth grand slam title at the Australian Open in January and then the Dubai Championships before heading to Indian Wells.
On a stifling hot afternoon, Djokovic and former US Open champion Del Potro treated the near-capacity crowd to some absorbing tennis on the Stadium Court as their opening set went with serve until the 10th game.
Del Potro, who had saved four breakpoints in a marathon eighth game, staved off a set point at 30-40 with a backhand volley winner but failed to repeat the feat on the second as he mistimed a forehand after a protracted baseline rally.
A set up, Djokovic surprisingly failed to hold in the first game of the second after hitting a forehand wide, then hurled his racket to the ground in disgust.
Though the Serb immediately broke back, he was again broken in the third when Del Potro steered a two-fisted backhand winner down the line.
Djokovic looked increasingly irritated and also failed to hold in the seventh when the towering Argentine struck a rasping forehand winner down the line to go 5-2 up.
Del Potro, who clinched the 2009 US Open, failed to serve out in the eighth, denied a set point at 40-30 by a Djokovic forehand crosscourt winner before being broken when the Serb struck a backhand winner.
However, Del Potro finally levelled the match in the 10th, on his third set point, after his opponent netted a backhand.
Djokovic came storming back in the final set, breaking the Argentine in the second game to race into a 3-0 lead but he failed to hold in the fifth as Del Potro pegged him back to 3-2.
The Serb did well to hold in the seventh, after trailing 15-40, but he was broken for the final time in the ninth when he hit a backhand long for Del Potro to serve out for the match.