Lucas Wallmark scored twice for the Swedes while captain Anton Lander also found the back of the net,
"We know we have players who can score goals on this team", said Sweden head coach Johan Garpenlov. "We may not have many pure goal-scorers, but we have lots of guys that can score.
"Today, Lucas scored two goals. Maybe next game it will be some other players."
Renars Krastensbergs and Nikolejs Jelisejevs scored for Latvia. Captain Lauris Darzins had assists on both goals.
"As we saw, the Swedes are quality", said coach Harijs Vitolins. "They play quality games and if you make mistakes, they can quickly score goals, which is why you must be ready every second.
"It was good that we came back and it gives us confidence for tomorrow."
Story of the game
Wallmark opened the scoring on Pontus Holmberg's pass from behind the net 9:42 into the game. On a power play late in the first period, his drive was almost tipped in by Carl Klingberg.
Just 30 seconds into the second period the lead was doubled as Klingberg intercepted an attempted clearing pass by Latvian goalkeeper Ivars Punnenovs and he found Mathias Brome for the initial shot, but Lander scored on the rebound.
Soon after, Wallmark took a needless double-minor for high-sticking Janis Jaks in the mouth. Latvia did have one good chance to cut the lead in the half, but Lars Johansson made a glove save on a tip by Ronalds Kenins.
Wallmark then seemingly put the game out of reach with a power-play tally. Despite not getting everything on his shot, the puck floated over Punnenovs and under the bar.
"We just played shift to shift", Vitolins said when asked about the team's mindset down 3-0. "I said 'we've got nothing to lose'.
"At this moment, 3-0 behind, we continued to play physical, to play our game. We said we needed to score the next goal and then we'll see."
When he went off for hooking with less than four minutes remaining in the period, the Latvians finally cashed in. Krastenbergs blasted one from the left faceoff circle that beat Johansson on his glove side.
It became 3-2 with 13:12 left in the game when Sweden was caught with too many men on the ice and after Garpenlov chose Wallmark to serve the penalty, Jelisejevs converted the rebound from a Darzins drive.
Sweden couldn't cash in on their own power-play opportunity when Rodrigo Abols was called for a check to the head. Punnenovs was pulled for the extra attacker with two minutes to go and Johansson stopped Uvis Balinskis' one-timer with seconds left to preserve the victory.
"Latvia is a good team", Lander said. "One thing they did really well was getting pucks in deep in the third period and coming harder on the forecheck.
"That's something we need to do the other way and keep things a little more simple."