A feisty battle among the basement dwellers goes the distance with Denmark edging the shoot-out verdict after a pulsating 2-2 tie.

Denmark took a giant step towards securing top-flight survival with a shoot-out victory against Latvia - but the Baltic nation was the width of the post away from snatching its first victory of the 2016 World Championship when Kristaps Sotnieks hit the piping in the last second of regulation.

Buoyed by that late reprieve, the Danes killed the remainder of a penalty call on Mads Christensen and eventually took the verdict when Nicklas Jensen got the shoot-out winner. He took his time on the approach to Elvis Merzlinkins' net and tricked the young Latvian goalie into committing early before slotting the puck home. That, coupled with two saves from Sebastian Dahm, was enough to settle the outcome.

Only a regulation victory for Denmark would make survival mathematically certain but the two points mean that it would take an unlikely sequence of results for both Latvia and Kazakhstan to overtake the Danes. Latvia, meanwhile, moves one point clear of eighth-placed Kazakhstan ahead of the teams' game on Saturday evening.

For Denmark's Lars Eller, meanwhile, it was a welcome way to banish the unhappy memories of the 10-1 hammering against Russia 24 hours earlier.

"We all knew we didn't play well last night," Eller said. "It was embarrassing to be out there. But today, although we didn't play a beautiful game, we played with our hearts. We got the two points that we needed."

With so much at stake for both teams, it was perhaps not surprising that the game got off to a cautious start. Neither goalie had been seriously tested until the Danes converted the first power play of the night to go up on a mighty Nicklas Jensen shot in the 12th minute. Jensen's wrist shot from the top of the right-hand circle was so well hit that it flew out of the net before the officials could confirm the goal: a check of the video proved the shot was on target.

That was just the boost Denmark needed after that mauling against Russia, but the lead was shortlived. Latvia turned the game upside down thanks to two power play goals either side of the first intermission. Roberts Buckarts created them both, first with a pass slid across the face of the net for Andris Dzerins to rifle home a one-timer from the face-off spot. Then, early in the second period, he got behind the net and picked out Kaspars Daugavins for a decisive low finish.

Denmark did not buckle and tied the game just before the halfway mark when Morten Poulsen smacked down a Mads Boedker slap shot to send the puck between Elvis Merzlikins' pads. 2-2, and the excitement was only just starting.

The Danes had a great chance to get a stranglehold on the game when Aleksejs Sirokovs was expelled from the ice for a check to the head of Emil Kristensen and Latvia's problems intensified when Zemgus Girgensons took an interference call to give the Vikings a 5-on-3 advantage for fully two minutes.

There was a further skirmish after Jensen was denied on the doorstep and got into a rumble with Maris Bicevskis, while Mezlinkins pulled off a smart glove save to stop Lars Eller when he carved out a clear look at the net as the second stanza came to a breathless halt. Latvia's joy at killing a big penalty highlighted how much of an opportunity had passed Denmark by but captain Daugavins admitted that it came at a high price.

"That match penalty killed our momentum," he said. "After that, we had no gas. Power plays and penalty killing. That was the difference today."

"We needed a goal there. We knew that, but we kept going. We didn't quit. We got a goal that we needed," he added.

Despite Daugavins' pessimistic assessment Latvia created the better opportunities in the third period but a combination of wasteful finishing and good goaltending from Sebastian Dahm kept the Baltic team at bay. Gints Meija failed to make good contact in front of an empty net early in the stanza after Dahm beat away a slap shot. Later, Dzerins was left in despair as he fanned his shot wide after Bukarts led an odd-man rush that could have decided the outcome.

For Denmark chances were harder to come by, but Merzlinkins still had to be alert to block a teasing rush from Lars Eller in the 56th minute. There was a further heart-stopping moment for Latvia with just 74 seconds left when Oliver Lauridson pinged a slap shot against the bar after the goalie made a big stop from Nikolaj Ehlers at the near post.

There was still time for Latvia to earn a power play with 37 seconds left, enabling Kristaps Sotnieks to rattle the post with a shot from the point in the final seconds, but the game was destined for overtime and a shoot-out.