Russia struggled to take control in the second period but finally equalized with 11 minutes when Malkin's slapshot of Sergei Gonchar's pass beat Germany goalie Robert Zepp.
Both teams had good chances in the third period but Datsyuk stole a pass in the German zone and streaked down the ice before beating Zepp to the upper left corner from the left side.
In the first semifinal, Karel Rachunek scored with 7.5 seconds left in relegation to force overtime, then Jan Marek hit home in the shootout to give the Czechs the win.
Johan Harju's power-play goal opened the scoring for Sweden eight minutes in. But Tomas Mojzis leveled in the 18th.
Sweden regained the lead with eight minutes remaining in the second period on Andreas Engqvist's goal, setting up Rachunek's score just before the final buzzer.
After a scoreless extra session, the Vokoun stopped Magnus Johansson and Tony Martensson in the shootout.
Sweden, the 2006 champion, will be playing for its second straight bronze medal.