Switzerland fell to 1-1 and the Czech Republic improved to the same record while Latvia has yet to win a game in the tournament.
Sweden's Henrik Lundqvist of the New York Rangers put on a goaltending clinic on Friday but he was almost matched by Switzerland's Reto Berra.
Had it not been for the rebound that Alfredsson was able to put home off a shot by Erik Karlsson, the game would have likely ended up in overtime.
The victory for Sweden is bittersweet after the team received news that team captain Henrik Zetterberg will be out for the rest of the Olympics with a herniated disk in his back.
In the other contest, the Czechs were able to dominate offensively and they outshot Latvia 39-20.
“We didn't play very well in the first half of the game against Sweden, but we played better in the second half of this game, so we have to wait for tomorrow [against Switzerland] to see what kind of team we really are," Jagr said.
He will celebrate his 42nd birthday on Saturday.
"He's like a fine wine, he just keeps getting better with age," said Latvian coach Ted Nolan. "As I told someone before, he is almost like a ballerina on ice; he's so smooth and slick. He's a world-class player. Today, he proved how good he is again."