In doubles, Vancouver's Vasek Pospisil and American partner Jack Sock, the Wimbledon champions, reached the final by beating Poland's Marcin Matkowski and Serb Nenad Zimonjic— former partner of Toronto's Daniel Nestor— 6-3, 3-6, 10-6 (match tiebreak).
The pair will play for the title against Italians Fabio Fognini and Simone Bolelli. The Pospisil team advanced on their first match point after 70 minutes.
"It was a tough battle," said Pospisil. "I was feeling incredible the first set and a half, and then I think Jack really picked it up in the end. I think overall we played a solid match."
Raonic, from Thornhill, Ont., rained down 18 aces in a nearly three-hour struggle in which the sixth seed held his nerve throughout to deny Nadal a spot in Saturday's semifinals against Roger Federer.
Instead Raonic will line up against the four-time champion after beating Nadal for the first time in six meetings.
"I'm about as happy as I can be," said Raonic, who has improved his showing at this desert venue with successive appearances. "Obviously there was a lot of up and down through that match, and all I could ask of myself was just keep competing and hope to find a way.
"I got fortunate a few times and it worked out. But there is a day of work tomorrow and I have to prepare for that. I need to keep up the momentum."
Federer booked his place in the semis as he crushed Tomas Berdych 6-4, 6-0.
The ATP No. 2 has won eight of nine against Raonic, with the 24-year-old Canadian catching the Swiss with a win at Paris Bercy last November indoors.
"I think I have a good understanding of what I need to do against Roger," said Raonic. "Obviously that's the easiest part, understanding it, rather than doing it.
"I've just got to keep calm, keep collected, and just try to figure out solutions and adjustments as they come."
Raonic lost the opening set against Nadal but turned in an heroic second to level after missing on multiple set points.
In the third, Raonic did not waver, matching Nadal toe-to-toe and breaking for 6-5.
The Spanish third seed saved a break point in that game earlier, but could not handle a Raonic return that dropped dead on the baseline.
A game later, Raonic sent over an ace for a match point and took victory as Nadal sent a return wide.
Raonic ended with 48 winners and 59 unforced errors in his controlled display of power tennis. Nadal finished with just 25 winners.
Raonic has now advanced to the quarter-finals or better at eight of his last 10 Masters 1000 events— a feat matched only by Federer.
Nadal swept up the opening set in quick fashion after 38 minutes thanks to his single break of Raonic's serve in the third game.
But life got more complicated for both players in the second as Raonic began to get stuck into his game and concentrated as much on holding his nerve as in diffusing the shot-making genius of his opponent.
Raonic played even with the Spaniard as he saved break points to hold for 3-2 and again for 5-4. But the Canadian missed a chance to level at a set each as he missed on two set points in the tenth game.
Raonic drove an easy forehand into net on the first and could only watch as Nadal fired an ace on the second as the set went to a tiebreaker.
The tension tightened in the decider, with Nadal failing to convert on three separate match points. Meanwhile Raonic had difficulties with set-point chances before finally converting after 81 minutes when Nadal hit the net with a return.
"When I was playing those match points it didn't really feel like match points, they were just like another point that I was trying to get through," said Raonic. "I can only remember one, but I don't even remember the last two.
"It was going through the paces at that moment of what do I need to do now, not really signifying it as a match point."