Raonic, the No. 6 seed from Thornhill, Ont., struggled early and was hampered by unforced errors on the stadium showcourt at Rexall Centre. Lopez will next play the winner of the late quarter-final between No. 2 Roger Federer of Switzerland and No. 5 David Ferrer of Spain.
Jo-Wilfried Tsonga of France reached the semifinals earlier in the day with a 7-6 (5), 4-6, 6-4 victory over Britain's Andy Murray. Seventh-seeded Grigor Dimitrov of Bulgaria also reached the final four by outlasting South Africa's Kevin Anderson 5-7, 7-5, 7-6 (6).
Raonic seemed handcuffed at times by Lopez's unique style. The crafty left-handed Spaniard mixed things up with cut shots, chip-and-chase strokes and a nice variety of drops and lobs.
Raonic almost always answered with powerful ground strokes and the results were mixed. He was spraying shots and had a number of mishits.
His frustration was evident at times.
At 2-2 and with serve in the opening set, Raonic shouted out in frustration after dropping the first two points of the game. His next shot went long and another mishit gave Lopez the first service break of the match.
Raonic threw an exasperated look at his coach at the changeover and couldn't pull even, with Lopez sealing the set with an overhead smash.
The Canadian came out strong in the second set by taking the first five points. He was still having trouble with the spin on some of Lopez's shots but play started to open up with longer rallies and better flow.
The players went back and forth with mini-breaks in the tiebreaker. Raonic converted his first set point when Lopez fired a ball long as he tripped while approaching the net.
Raonic had a glorious chance to pick up a break at 2-2 in the deciding set. He had a triple-break point opportunity and after nine deuces, Lopez held to keep things on serve.
The Spaniard made his move by breaking Raonic before closing out the match in one hour 57 minutes.
Earlier, the 13th-seeded Tsonga picked up his second straight upset victory by knocking off the eighth-seeded Murray, who had won nine of 10 previous meetings against the Frenchman. Tsonga was coming off a convincing win over top-seeded Novak Djokovic.
"This week is kind of rewards for me," Tsonga said. "To play like this, to beat two guys in the top 10. It's good and I hope it will continue."
Tsonga, who had an 18-7 edge in aces over Murray, won 83 per cent of points when his first serve was in.
"I was able to serve maybe 220 (km/h) all match and for me it's something great when I'm serving like this," Tsonga said. "I'm able to play good tennis."
Murray said it was a much faster-paced match than his tournament opener against Nick Kyrgios. The two-time Rogers Cup champ had reached the quarter-finals on a walkover when Richard Gasquet withdrew due to an abdominal injury.
"Jo is a top player, he's a fantastic athlete," Murray said. "When his game is on, he's very tough to beat."
In men's double play, the third-seeded team of Toronto's Daniel Nestor and Nenad Zimonjic of Serbia advanced with a 2-6, 6-3, 14-12 win over No. 5 Julien Benneteau and Edouard Roger-Vasselin of France.
No. 4 Ivan Dodig of Croatia and Marcelo Melo of Brazil beat seventh-seeded Spaniards Marcel Granollers and Marc Lopez 4-6, 6-4, 10-8. The second-seeded duo of Alexander Peya of Austria and Bruno Soares of Brazil defeated Jean-Julien Rojer of the Netherlands and Romania's Horia Tecau 7-6 (4), 6-4.
Federer was the highest-seeded player left in the singles draw after three of the top four seeds were eliminated Thursday. He has won all 14 of his previous meetings against Ferrer.
Raonic, meanwhile, was coming off a tournament victory last weekend in Washington. He has split four career meetings against Lopez.
The 23-year-old Canadian has six career wins on the ATP Tour but is still looking for his first Masters 1000 title. He was pushed to three sets in all three matches at the US$3.78-million tournament.
Raonic reached the final at last year's Rogers Cup in Montreal before losing to Rafael Nadal. The Spaniard is not back to defend his title due to a wrist injury.