In Moscow, Johan Akerman scored and Johan Backlund made 38 saves in Sweden's 1-0 win over Finland.
In a rematch of the gold medal game at the Turin Olympics, Sweden and Finland played a free-flowing game that featured superb goaltending at both ends.
However, Finland goalie Kari Lehtonen made one mistake.
On Akerman's long shot from the blue-line, Lehtonen gloved the puck but it popped out and trickled across the line at 15:53 of the first period.
"I was very surprised," Akerman said. "I had turned my back on the play and didn't even see it go in the net. The last thing I saw was the puck going high and wide and he was moving to catch it."
Needing a regulation-time win to advance, Belarus pulled goalkeeper Andrei Mezin for the extra attacker more than a minute before the buzzer. Demitra then sent a pass from Marian Gaborik into the empty net with 39 seconds left.
Zdeno Chara of Slovakia and Aleksei Ugarov of Belarus each scored in the first period.
The Slovaks reclaimed the lead when Gaborik scored back-to-back goals in the first five minutes of the second period. Belarus again replied with Oleg Antonenko scoring at 13:47 and Konstantin Koltsov adding the tying goal 30 seconds later.
"We talked about not underestimating them and at the beginning I think we did a bit," Gaborik said.
In Moscow, Ilya Kovalchuk scored a goal and set up another to lead Russia over Switzerland 6-3.
Alexander Ovechkin was ejected from the game at 8:42 of the first period for a check to the head of Valentin Wirz, who needed to be helped off the ice. IIHF officials said Ovechkin could face disciplinary action.
In relegation round play, Ukraine defeated Norway 3-2 to keep alive its hopes of remaining in world hockey's elite division.
Both teams still have a chance to play in the top division next year. Ukraine must beat Austria on Monday, while Norway needs to beat Latvia and have Austria beat Ukraine.