Thiem, who was a break up in the third set when weather forced play to be suspended on Friday, beat the world No. 1 6-2, 3-6, 7-5, 5-7, 7-5 after more rain led to another stoppage.
He will face defending champion Rafael Nadal on Sunday in a rematch of the 2018 final.
Thiem served to make it 4-1 in the third set, winning some impressive points along the way. The best was a forehand down the line 26 shots into the point.
Djokovic looked in trouble, but he held firm on serve for 4-2 and then broke to reduce the gap further. Thiem's speed across court was causing problems, though, and a sliced backhand at the net, followed by a high backhand winner, increased the pressure on Djokovic.
Djokovic held to draw level in the set, but Thiem's sliced backhand continued to keep Djokovic on his heels. Fortune was also on the Austrian's side when he skimmed a shot off the top of the net to force deuce in his next service game.
It proved a key moment, as Thiem held to reassert himself in the set.
Djokovic needed a change of tack and promptly deployed a series of kick serves. The tactic forced Thiem on to his back foot:
Thiem was also kept off guard when Djokovic started to mix in some shorter serves. Even so, the 25-year-old held his nerve to close out the set in style.
Djokovic had been unhappy with how quickly the umpire was announcing the score between points and wasn't shy about making his feelings clear amid concerns about the shot clock:
A sense of injustice and being pushed to the brink brought out the best in Djokovic, who raced into a 4-2 lead in the fourth set.
However, Thiem fought back brilliantly to force his way into a 5-4 lead and within one game of a memorable win. It left Djokovic having to hold to stay in the tournament.
He did so thanks to a pair of unforced errors by Thiem, and mistakes continued when Thiem went back on serve. A double-fault gave Djokovic a priceless break and the chance to take the match to a fifth set, and the Serb seized it.
Momentum was with Djokovic, but he almost failed to hold after letting a 40-15 lead slip early in the fifth. He protected serve, however, to even the decider at one game apiece.
A misjudged forehand, far from Djokovic's first on the day, helped Thiem save a break point and move ahead again. Thiem then converted a break point in the next game before holding for a 4-1 lead.
Sadly, the covers were soon brought out as rain reappeared with Djokovic working to save another break point.
Once play resumed, Djokovic reeled off two straight wins, including earning a break when Thiem went long on a lob. However, Thiem sensationally broke back and then served for the match.
Things didn't go the fourth seed's way, though, as he blew a 40-15 lead and allowed Djokovic to break back. And then the 32-year-old held to even the set at 5-5.
Thiem's response was an emphatic hold without a single dropped point. He then sealed victory with a magnificent forehand to end the remarkable match.