Trailing 2-0 going into the final period, Switzerland came to life with goals from Sara Benz, Phoebe Stanz, Jessica Lutz and an empty netter from Alina Muller.
"It's an amazing feeling," Muller told reporters. "It's amazing we came back from 2-0 down." Canada and the United States will play for the gold later on Thursday.
Sweden, the 2006 silver medallists, had looked comfortably on course for the win as they controlled the first two periods.
But Switzerland fought back with two goals in the opening six minutes of the last period, first when Benz pounced on a loose puck near the top of the crease and five minutes later when Stanz tallied on a powerplay.
With under seven minutes to play and the game tied, Sweden were unable to clear their zone and the Swiss made them pay as Lutz sent a perfect pass from Lara Stalder flying into the net.
Muller's empty-net goal with 67 seconds to play proved crucial to Switzerland's medal hopes as Sweden managed to get one back in the closing minute of a wild period.
The final buzzer set off a crazy celebration among the Swiss players, who mobbed each other in the corner of the rink. The despondent Swedish team were littered on the ice and their bench staring down at their yellow jerseys.
"It sucks. We have been playing really well through the tournament but we lost all of it in that third period," said Jenni Asserholt, who assisted on Sweden's last-minute goal. "It feels really tough to accept. We just messed up."
After finishing last in their group during the preliminary round, Switzerland beat Russia in the quarter-finals before losing in the semi-finals to Canada.
Since women's ice hockey made its Olympic debut at the 1998 Nagano Games, Canada and the United States have competed for every gold medal except one. The lone exception came in 2006 when Sweden lost to Canada in the final.
Finland and Sweden had been the only countries apart from the two North American ice hockey superpowers to reach an Olympic podium, a trend that put the women's tournament under the microscope in Sochi.
"Hopefully, we can just get better from here," said Stanz. "Women's hockey is going to be taken seriously, especially in Europe."
- Sports & Recreation
- Ice Hockey