The teams were tied at 1-1 after three periods in Cologne, Germany, with Victor Hedman scoring for the Swedes and Canada's Ryan O'Reilly equalising. There were no goals during overtime, but the Swedes then scored twice in the shootout, while Canada failed to score.
Swedish goalie Henrik Lundqvist made 41 saves in total and became a sporting hero when the national team, known as Tre Kronor or Three Crowns, beat Canada by 2-1.
"I'm so happy, it's fantastic, Lundqvist told Swedish Radio after the game. He said: "I came here aiming just to get through it. The boys worked like animals. It was a fantastic feeling to be part of this group."
Sunday's win meant Sweden dethroned last year's champions and beat Canada for the first time since the play-off system was introduced in 1992. It is Sweden's tenth world title.
Lundqvist praised both the team management and medical team, which treated him for a minor joint injury before the game. He also said it was a dramatic game.
"It was full speed and their defence was fantastic," Lundqvist said of the Canadians.
This is Lundqvist's first world gold medal and he will receive a heroes' welcome today, along with the rest of the ice-hockey team as they land at Stockholm's Arlanda airport this afternoon. After a press conference at the airport, they will be celebrated at the Sergels Torg square in central Stockholm