It was worth the wait. Hungary earned its first Worlds victory in 77 years, topping Belarus 5-2. The win preserves Hungary’s hopes of avoiding relegation.

Meanwhile, Belarus finds itself in a precarious position. It has one round-robin game left against France on Tuesday. The former Soviet republic, which finished seventh in 2014 and 2015, has not been relegated since 2003. Both Hungary and Belarus now have three points.

It was an emotional game. The last Hungarian victory at the Worlds was an 8-1 romp over Belgium in Zurich, Switzerland on February 3, 1939.

"I got goosebumps right now," said a tearful Csanad Erdely. "This is a great feeling that we can give a little back to the fans."

Here, the Hungarians squandered a 2-0 first-period lead, but showed great character as they rallied to claim the three points on Saturday.

"Now hopefully we have a chance to stay up," said Hungarian head coach Rich Chernomaz. "We have a chance to see how we do against Germany and how Belarus does against France. We have a chance because of the way we played tonight."

Geoff Platt and Artus Gavrus scored for Belarus, and Andrei Stepanov had two helpers.

"There are a lot of things different with this year's team from last year's," said Belarus head coach Dave Lewis. "We have to do a better job on special teams and our goaltending has to be better. There are a bunch of things we have to improve. "

Hungarian goalie Miklos Rajna earned the win as Belarus outshot Hungary 19-17. Hungary's last Group B game is on Monday against Germany.

"It is great getting into the history books, and this was a team effort," said Rajna. "We stuck to the plan today."

The atmosphere was loud and proud at Yubileiny as loud chants of “Belarus!” competed with the Hungarian fans’ ceaseless singing and drum-beating.

At 5:31, Nagy drew first blood for Hungary. With aggressive forechecking, Sarauer got the puck to Daniel Koger, and he set up Nagy in front to beat Belarus starter Kevin Lalande. It was the first time the newly promoted Hungarians have had the lead in this tournament, and it was well-deserved after they'd come out hard in so many games.

At 10:31, Hungary went up 2-0 while shorthanded. Sarauer fed the puck to Janos Vas on the rush, and when he tried to get the puck back to the net-bound Sarauer, a backchecking Platt inadvertently tipped the puck past Lalande. Suddenly, it looked like the hockey gods were on Hungary's side.

Platt atoned for his gaffe when he cut the deficit to 2-1 less than two minutes later. The naturalized Canadian forward collected the rebound from Stepanov's long shot and backhanded it home.

It was a great start for Hungary, which led by a goal after 20 minutes despite being outshot 10-4.

After the teams traded ineffective power plays to start the second period, Belarus tied the game at 6:43. By Rajna’s right post, Yevgeni Kovryshin eluded the checking of defenceman Bence Stipsicz, kicked the puck up to his stick and sent it cross-crease to Gavrus, who put it up over the Hungarian goalie.

Sebok gave Hungary a 3-2 lead at 10:32 on a spectacular breakaway, taking a long pass from Srizanyi and lifting the puck past Lalande’s stick side before sliding into the boards.

Hungary went up 4-2 at 13:49 on an odd-man rush. Gallo got past defenceman Yevgeni Lisovets at the Belarus blue line, burst in on the right side with Janos Vas flanking him, and held the puck before beating Lalande -- stick side again.

"After 2-2, we showed a lot of character and stuck with the plan," said Nagy. "We were able to get a few goals back and hold on to the lead."

The 4-2 goal marked the end for Lalande, who allowed four goals on nine shots. Coach Dave Lewis yanked the struggling Kingston, Canada-born netminder in favor of veteran Vitali Koval.

The Hungarians got another big opportunity with a two-man advantage that began with 48 seconds left in the middle frame. First Roman Dyukov went off for tripping, and then Oleg Yevenko was sent off with a double minor for high-sticking after he cut Istvan Bartalis. However, the Magyars couldn't cash in.

Midway through the third period, Rajna made a key save on Charles Linglet from the slot, as the crowd roared with excitement. The Belarusians pressed hard in the dying moments. They pulled Koval for the extra attacker with 1:27 left and then Koger was sent off for slashing the stick out of Stepanov's hand.

But Janos Vas scored an empty-netter with four seconds left to round out the scoring. Both the Hungarian bench and their fans erupted with joy. It was a little slice of modern-era IIHF history. At long last, the Hungarians would get to hear their national anthem officially played, instead of only the fans serenading their team after the post-game handshake.

"This is the first time we don’t have to sing the national anthem in a loss," said Erdely. "Seeing the flag being raised makes me so proud of these guys and that I am Hungarian."

This was just the second meeting between these two nations in IIHF history. Belarus beat Hungary 3-1 at the 2009 Worlds in Switzerland. The Hungarians lost all their games at that tournament.