The defending champion, came back from losing the first set to overhaul Nadal 4-6, 6-3, 6-4.
Raonic, the defending champion, came back from losing the first set to overhaul Nadal 4-6, 6-3, 6-4, disappointing the sell-out crowd who were almost all cheering for a Spanish victory.
He will now play Bulgaria's seventh seed Grigor Dimitrov following a 6-3, 4-6, 6-3 winner over fourth ranked Dominic Thiem of Austria.
Raonic beat Roger Federer to win the 2016 title, the start of a successful year that saw him rise to three in the world.
But in the first set his serve was slightly off and Nadal took advantage, breaking in the fifth game to take the early lead.
Nadal had the chance to break again in the fifth game of the second set, but Raonic served his way out of trouble, saving the game with one of his 23 aces then breaking the Spaniard in the eighth game to level proceedings.
The Canadian then seized on a poor Nadal service game at the start of the third set to break him to love and when he fought off a break point of his own to go ahead 3-1, the momentum had swung to the defending champion.
Raonic, who lost to Nadal in the semi-finals of an exhibition tournament in Abu Dhabi last week, said he knew he had to be more aggressive if he wanted to win.
"He is always going to defend better than me, so I don't want to play him on those terms," Raonic said.
Nadal said a poor 10-minute spell had changed the match.
"I had 10 minutes that were very hard, and playing against a player like him, that's terrible," he said.
"He played aggressive, he played great, his returns on my serve during those games were very, very aggressive, and the serve was huge."
Stan Wawrinka and Kei Nishikori will meet in the second semi-final following contrasting wins.
Second seed Wawrinka battled for over two-and-a-half hours before seeing off rising British player Kyle Edmund 6-7 (2/7), 6-4, 6-4, before Nishikori, the third seed, demolished young Australian Jordan Thompson 6-1, 6-1.
Wawrinka, the reigning US Open champion, looked out of sorts against an inspired Edmund, who dominated the match for long periods and deservingly won the first set.
But the 31-year-old Swiss scrambled well and was able to break Edmund once in the second set to level the match.
Wawrinka then went up to breaks in the decider to serve for the match and 5-2 and although Edmund got one break back he couldn't complete the comeback.
Nishikori was in complete control against Thompson from the outset.
He dominated from the baseline and gave the Australian no chance, winning in just 61 minutes.
"I think I played one of my best matches so far, really dominating from the baseline and serving good today," Nishikori said.
"Everything was working well."