Ristolainen picked up the puck along the right boards, beat defenseman Robert Hagg as he cut in front of the goal and slid a backhander under goalie Oscar Dansk's right leg pad.
"I saw that they played man-on-man defense in their own end," said Ristolainen, who has one goal in 19 games this season for Buffalo. "It was empty in front of the net. I just skated there. I tried just to put the puck somewhere hard and it went in."
Finland also won the under-20 event in 1987 in Czechoslovakia and 1998 at home in Helsinki.
"Nobody trusted us to win, but we trusted," said Chicago prospect Teuvo Teravainen, the tournament scoring leader. "We knew we were going to be a good team and we had a chance to win this tournament. It's an awesome feeling right now."
Sweden tied it at 2 on Christian Djoos' power-play goal with 9:07 left in the third period. The Washington draft pick beat goalie Juuse Saros with a slap shot through traffic from the high slot.
"We were playing in their zone the whole game," said Swedish captain Filip Forsberg, the Nashville forward selected the tournament MVP. "Obviously, it's hard to lose like this."
Sweden lost after winning its first six games in the tournament.
"It's just frustrating and really sad at the same time that we didn't pull through in the end," said Gustav Olofsson, a Minnesota prospect who plays at Colorado College. "You're that close. There's no excuse for it."
Finland's Era Lindell -- drafted by Dallas -- scored 28 seconds into the game, and Lucas Wallmark tied it on a power play at 7:53 of the second. Finland regained the lead 45 seconds later on Nashville draft pick Saku Maenalanen's goal.
Saros, also drafted by Nashville, made 35 saves.
"Their goalie was really good today," Wallmark said. "It was tough for us."
Teravainen had three assists. He won the scoring title with 15 points on two goals and 13 assists, and Maenalanen topped the goals list with seven.
"It's excellent how the team has grown," Finnish coach Karri Kivi said. "It was kind of a fairy tale. The painful moments during the tournament made us grow."
In the third-place game, Russia beat Canada 2-1.
Buffalo center Mikhail Grigorenko and Eduard Gimatov had first-period goals for Russia, and Josh Morrissey scored for Canada in the third.
"When you put on this crest and try to represent your country and can't even bring a medal back to Canada to the people who've been cheering for you, and have 4,000 fans come down here, it's heartbreaking," Canadian captain Scott Laughton said.
The Canadians won the last of their record 15 titles in 2009. They also lost to Russia in the third-place game last year in Ufa, Russia.
"We beat them again, so it's a good time right now," Grigorenko said. "It's a tough game to prepare for, but once it starts you just play hockey and want to win the game."
In the semifinals Saturday, Finland beat Canada 5-1, and Sweden topped Russia 2-1. The United States, the winner last year, dropped out Thursday with a 5-3 quarterfinal loss to Russia.
Germany beat Norway 3-1 for a 2-1 victory in the best-of-three relegation series. Germany will remain in the competition next season in Montreal and Toronto, while Denmark will take Norway's spot in the 10-team event. Frederik Tiffels, Dominik Kahun and Patrik Klopper scored for Germany and Marvin Cupper made 34 saves.
The 31-game tournament drew 144,268 fans, breaking the European record of 139,680 set in 1998 in Finland. The overall record is 453,282 in Ottawa, Ontario, in 2009. The championship game crowd of 12,023 at Malmo Arena also was a European record.