Federer looked on course for victory when leading two sets to one but the Swiss was halted first by a thigh problem and then his gutsy opponent, as Raonic sealed a 6-3 6-7 (3/7) 4-6 7-5 6-3 triumph.
Raonic, coached by John McEnroe, will be the first Canadian man to play in the major final when he faces Scotland’s Andy Murray tomorrow.
“It’s an incredible comeback for me,” Raonic said.
“I was struggling through the third and fourth set, he was playing some really good tennis. I managed to turn it around and played a really good match.
“It’s a great feeling to be giving myself a chance to play in my first final.”
Federer squandered three break points in the fourth set and fatigue may have caught up with the 34-year-old, who twice called the trainer to look at his thigh and had not played consecutive five-setters since 2013.
With Novak Djokovic out, this was Federer’s greatest chance of winning an 18th major title since 2012 and while the veteran showed form to suggest he is still capable of adding another to his collection, doubts about his stamina and endurance remain.
At the end, he saluted all corners of Centre Court, prompting speculation that he might be bidding farewell for good.
However, he insists retirement is not on the agenda.
“To be very clear for you, I hope to be back on Centre Court,” he said. “It (the gesture) was a thank you for the crowd. That’s what I was going through, not thinking that this might be my last Wimbledon.”
Murray, meanwhile, cruised into the decider after comprehensively defeating Tomas Berdych.
The Centre Court crowd are used to being put through the mill by the world number two at this stage of the tournament, but he was simply far too good for the 10th seed and eased to a 6-3 6-3 6-3 victory.
Murray has now reached more slam finals than any other British player, surpassing the mark he jointly held with Fred Perry, and there is no doubt the Scottish star will be expected to repeat his 2013 triumph, which finally ended Perry’s 77-year reign as the last home winner of the men’s singles title.
Murray said: “I’m obviously very happy. It was a good match today.
“The middle part of the second set was really key. He had a few chances to go up a break and then I broke in the following game, and that was big.
“To make a Wimbledon final is a good achievement and I’ve got one more to go on Sunday.
“The older you get, you don’t know how many chances you’ll have to play in grand slam finals so you want to make the most of your opportunities.
“I’m glad I managed to get through today.”
The Scot added: “I’ll need to play a great match on Sunday if I want to win.”
Asked about his Aegon Championships win over Raonic, which came just last month, Murray said: “It was a very tough match. Three sets, and I was down a set and a break but I managed to turn it around.
“He’s playing probably the best grass-court tennis of his career.”