Latvia edged Denmark 4-3 in a shootout in Game Three of the relegation series. The Latvians stay in the elite division for 2017, while the Danes are relegated.

Deniss Smirnovs scored the shootout winner low to the stick side. Then Denmark's Rasmus Heine lost the puck when he attempted the same backhand move that had worked earlier in the shootout, and the game was over.

"In that moment you just feel so fantastic," said Latvian captain Tomass Zeile. "It’s so huge for Latvia."

Latvia rallied late from a 3-1 third-period deficit to force the extra session.

"I think we played a pretty good game for the first two periods," said Danish captain Christian Mathiasen-Wesje. "In the last 10 minutes of the third period, we got scared of making mistakes. We messed it up and they scored two goals."

Smirnovs also scored in regulation for Latvia. Renars Krastenbergs notched a goal and an assist, and Zeile had the other goal.

It's a big relief for Latvia, which won the first relegation game 5-1. Denmark bounced back in Game Two with a 4-1 win. The last time Latvia was relegated was in 2013.

"Sometimes in games when we’re losing by two goals, everyone’s head is down and it feels like you’re losing even in the locker room," said Zeile. "I think today we kept our emotions up in the room and helped each other. I think we wanted it a little bit more than them."

Oliver Gatz and Andreas Grundtvig both had a goal and an assist for Denmark, and Mathiasen-Wesje also scored. Danish goalie Kasper Krog did his best in a losing cause at the Ralph Engelstad Arena as Latvia outshot the Danes 41-25.

"He played a really great game for us," Mathiasen-Wesje said of Krog. "We took stupid penalties and we didn’t block shots for him. We didn’t take the man in front."

The Danes have only managed to avoid relegation at the U18 level once before, back in 2004.

Discipline was an issue here for the Latvians, who totalled 37 PIM in the 11:00 game on Sunday. With that said, the Danes also took 16 PIM, and it cost them in the third period.

"At the end, we were a little too nervous in my opinion," said Danish coach Martin Struzinski. "Mentally, our guys aren’t used to things like this at this level. They experienced a lot through this and hopefully they’ll get stronger out of it as human beings and hockey players."

The Danes weathered an early Latvian power play after Magnus Molge was sent off for tripping. They opened the scoring at 11:31 on their first man advantage. During a goal mouth scramble, Mathiasen-Wesje was Johnny-on-the-spot to bang a rebound past Latvian starter Gustavs Grigals.

Near the three-minute mark of the second period, Molge was shaken up on an Erlends Klavins hit in the Danish end and received attention from the trainers. His teammates helped him off the ice, while Klavins was ejected with a five-minute major for boarding.

Compounding Latvia’s woes, Krastenbergs was sent off for delaying the game after he put the puck over the glass in his own zone. The Danes capitalized on the ensuing 5-on-3, as Krag’s slapper from the top of the right faceoff circle was tipped in by Gatz for a 2-0 lead at 4:05.

Denmark continued to press for the third goal as the second period wore on. Jonas Rondbjerg failed to score on a partial breakaway. Krag’s quick release from the faceoff dot was gloved down by Grigals.

With Mathiasen-Wesje in the box for tripping, Latvia cut the gap to 2-1 on the power play at 4:57 of the third period. Krastenbergs fooled Krog with a quick wrister through traffic.

The Danes soon responded. Grundtvig powered off the side boards to the slot and flung a wrister past Grigals to restore the two-goal lead at 8:17.

At 13:56, Latvia capitalized again with the man advantage as Smirnovs whipped one past Krog's glove to make it 3-2.

The Latvians got the equalizer and rejoiced wildly when Zeile floated one past Krog from the center point with 1:07 remaining in regulation.

"The puck just came to me," said Zeile. "In my head, I said: ‘Just shoot!’ I shot it and it went top shelf."

Both sides had good chances in overtime, but couldn't cash in. The Latvians switched to goalie Marek Mitens for the shootout.

"We knew he’s a better goalie at penalty shots so we had confidence," said Zeile. "We weren’t so shocked about it."

Despite the disappointment for Denmark, there are many positive things happening with their program overall. For the second straight year, the Danish U20 team made the quarter-finals at the 2016 World Juniors in Finland. And Denmark will host the IIHF World Championship for the first time ever in 2018 in Copenhagen and Herning.