It was Goffin's 42nd victory in 44 matches since his straight-sets loss to Andy Murray at Wimbledon, and the first time the 23-year-old Belgian has beaten a top-10 player.
"It's one of my nicest victories, if not the nicest," the seventh-seeded Goffin said. "It's really pleasing. I can't really comprehend what I've achieved since Wimbledon: more than 40 victories, two titles ... I think I'll only realize what I've achieved when I'm on holiday."
Later Friday, teenager Borna Coric upset second-seeded Rafael Nadal 6-2, 7-6 (4) to announce himself as one of the rising stars of tennis.
Nadal announced after the match he will have season-ending appendicitis surgery. He was playing just his third tournament since Wimbledon due to a wrist injury and looked nowhere near his best.
"It was difficult in the whole match, in the whole tournament," Nadal said. "Every day I felt more tired, I tried to practice, to get fit but it was not possible. The past four, five months have been very tough for me. It's been difficult to play and compete."
Coric, meanwhile, was in sparkling form.
"It's an unbelievable feeling," Coric said. "I'm so proud of myself and I hope I can play the same game tomorrow.
"There was pressure but I didn't have anything to lose, because if I lose I lost to the No. 1 in the world. I never played against him so I didn't know what would happen, whether he would kill me or not."
There was no such slip-up for Roger Federer as the top-seeded Swiss remained on course for his sixth title in Basel after beating fifth-seeded Grigor Dimitrov 7-6 (4), 6-2.
In the Goffin-Raonic match, the Belgian broke early on but was broken back when serving for the opening set, shortly after some lights went out and halted the match for approximately 20 minutes.
The seventh-seeded Goffin saved another break point at the start of the second set before breaking in the penultimate game before serving to level the match. Goffin took a decisive lead in the seventh game of the final set and he threatened to break again but Raonic saved two match points — one with his 21st ace.
The Belgian finally converted his fourth match point when Raonic returned a powerful serve long. Goffin has won four Challenger and two ATP titles this year and played with confidence against the Canadian.
"I tried to make the most of my game after the lights went out," Raonic said. "I came back trying to serve harder. and hoping to find rhythm that way. I created some opportunities in the start of both sets, but I didn't make the most of them.
"He's been playing well. He has confidence in the tight moments due to how he's played the last four five months."
Also Friday, Ivo Karlovic defeated Benjamin Becker 6-4, 6-4.
The loss hurts Raonic's chances of earning a qualifying spot for the season-ending ATP event in London. Raonic, from Thornhill, Ont., will need a strong showing next week in Paris as he battles Andy Murray, David Ferrer, Kei Nishikori and Dimitrov for the last three spots in the eight-man field.
Raonic, who is 45-17 on the season and currently ninth in the points race, knows he needs to take advantage of his last chance at the Bercy arena starting Monday.
"I'm hoping in these next few days I can pick up my physicality by working in the gym," Raonic said. "All I can do is fight to the last point, whenever that might be. Hopefully it is later rather than earlier in Paris."
Canada's Vasek Pospisil will play in the men's doubles semifinals in Basel with temporary partner Nenad Zimonjic — the former partner of Toronto's Daniel Nestor — on Saturday.
Pospisil, from Vancouver, teamed up with American Jack Sock to win the Wimbledon title this season. They will play next week in Paris in hopes of qualifying for the year-end event in doubles.
With files from The Associated Press.