Mike Green scored the winner and had two assists for Canada who will face Russia in Sunday’s final after the Big Red Machine blanked Finland 4-0 earlier Friday.
Green raced down the right side and scored with a wrist shot from a sharp angle to make it 5-3 with just seven seconds to go in the second.
Swedish defenceman Doug Murray tripped at his own blueline allowing Green the time he needed to get a good shot away.
“I was going to pass the puck and I noticed their two defencemen bumped into each other,” Green said. “I didn’t know how much time was left on the clock and our forwards were standing still.
“But if I passed it we wouldn’t have had a chance to get it in so I just took off.”
Rick Nash, Dany Heatley, Jamal Mayers and Ryan Getzlaf also scored for Canada who beat Sweden in the semi-finals for the second-straight year.
Anton Strålman scored twice while Niclas Wallin and Fredrik Warg added singles for reigning Olympic gold medallist Sweden who last won the gold at the Worlds in 2006.
“We pressed them, and it was close but no cigar,” said Swedish coach Bengt-Ake Gustafsson. “They are a great team.”
Canada outshot Sweden 38-34 but neither goalie looked particularly sharp in front of a crowd of 13,026 at the Colisee arena in Quebec City.
Mikael Tellqvist took over from New York Rangers star Henrik Lundqvist in goal for Sweden to start the third period with Canada leading 5-3.
Gustafsson talked to Lundqvist during the break and decided to make the switch after Lundqvist allowed five goals on 28 shots in the first two periods.
“He was burned out,” Gustafsson said of Lundqvist.
Other than a 5-4 win over the USA in the round robin, this was the first serious test for Canada and the first time they came from behind to win.
Just as they had done throughout their first eight straight victories in Halifax, Canada played their good luck folk song Stan Rogers’ “Barrett’s Privateers” during the warmup in Quebec.
Heatley opened the scoring with his tournament leading 11th goal with just over five minutes gone in the first period.
The trio of Getzlaf, Nash and Heatley has been Canada’s dominant line all tournament and Friday was no different as they scored three goals and at times looked like they were playing a game of keep away with the puck in the Swedish zone.
Strålman tied the game with just 44 seconds left in the period beating Canada goaltender Pascal Leclaire who was playing without his goal stick after he accidentaly dropped it.
Mattias Weinhandl carried the puck behind the Canadian net and backhanded a short pass to Stralman who beat the stickless Leclaire to that same side.
The Swedes threw a scare into Canada early in the second as Green came down hit the post on a slapshot and the Sweden grabbed the puck and went down and scored five seconds later.
Wallin scored just 2:46 into the second. He took a shot in close and it ended up under Leclaire’s leg pad. Leclaire then accidentally kicked it into his own goal after losing track of the puck in his crease.
Getzlaf levelled the score at 2-2 just 1:12 later on a great individual effort. He beat Swedish defenceman Magnus Johansson with a hesitation move to the outside and then chipped the puck off the right shoulder of Lundqvist into the top half of the net.
Mayers then made it 3-2 for Canada. He picked up the puck in the high slot and waited for Lundqvist to go down before shooting.
Strålman got his second of the game as he fired a long wrist shot from the blueline that fooled Leclaire and tied the game 3-3.
But Nash, at even strength, and Green, on the power play, scored before the end of the period as Canada regained the lead 5-3.
Nash split the Swedish defence just inside the blueline to beat Lundqvist and make it 4-3.
Warg pulled the Swedes to within one goal late in the third period but they couldn’t get the equalizer.