The Austrian will meet 23-year-old Daniil Medvedev in Sunday's final after the Russian also pulled off a surprise by edging out fourth seed Kei Nishikori 6-4 3-6 7-5 in a tight match.
Thiem had lost his last two matches against world number two Nadal, at Roland Garros as well as a thrilling five-setter in the U.S. Open quarter-finals, but he won their last meeting on Spanish soil, beating the Mallorcan in last year's Madrid Open.
The Austrian, ranked fifth in the world, broke Nadal to take a 3-2 lead in the opener and held in the next game thanks to a stunning crosscourt forehand winner before seeing out the set.
He broke Nadal again and was serving for the match but Nadal dug deep to earn three break points only to lose each one, Thiem levelling the game with an ace after a marginal call from the umpire.
He sealed his fourth career victory over Nadal in 12 matches with a softly-struck backhand, ending the Spaniard's chances of a fourth consecutive Barcelona Open title.
Rafa Nadal cae en las semifinales del Conde de Godó ante Dominic Thiem
Image credit: Getty Images
"I'm always super proud if I beat him because he's the best player ever on this surface, and it's always very special to beat him here on clay," Thiem told reporters.
"We always had great matches in the past, and also today was very good and I was more lucky today and I got the win."
Nadal, long regarded as the king of clay, has struggled for form on the surface of late, losing in the semi-finals of the Monte Carlo Masters and having a poor tournament in Barcelona.
Image credit: Getty Images
He dropped a set for the first time in four years at the event in his opening match against Leonardo Mayer and conceded he has been far from his best.
"This has been a complicated week for me, especially at the start. Today I enjoyed playing tennis again, I lost against a top rival and I was competitive until the end," Nadal said.
"What I needed to do was play more games like this to have a chance of victory. It has been a good base for what is to come. There are some victories which hurt you and others which can help you and this is one of those."
Twice Barcelona champion Nishikori beat Medvedev in the final of the Brisbane International in January but the Russian took an early advantage by breaking the world number seven in the seventh game.
Medvedev comfortably saw out the set but was pegged back by the Japanese, who won five games in a row to take the second set and make an ideal start to the decider.
Medvedev, ranked 14th, soon broke back to level the match and as both players consistently held their serve a tiebreak looked inevitable.
But Medvedev earned the first match point with a down-the-line winner and needed only one opportunity, clinching an entertaining match that lasted two hours and 25 minutes when Nishikori found the net with a forehand.
Sunday's final will be Medvedev's third of 2019 but his first final on clay.