Germany's national ice hockey team qualified for the 2018 Winter Olympics in Pyeongchang with a 3-2 victory over Latvia in Riga on Sunday.

Tom Kühnhackl of the Stanley Cup champions, the Pittsburgh Penguins, got the winning goal at 14:51 of the third period.

Leon Draisaitl and Felix Schütz had put Germany in complete control as they went into a 2-0 lead early in the second period.

However, Latvia, playing in front of a loud home crowd, fought back to even the score at 2-2, early in the third period, putting the game on a knife edge until Kühnhackl's winner eight minutes later.

"Things couldn't be going any better for me at the moment," Kühnhackl told German broadcaster Sport 1 afterwards. "When you are up 2-0, nerves play a role. But we stood together as a team," he said.

This was Germany's third win in their three games in the Olympic-qualifying tournament, after a 5-0 win over Japan and a 6-0 win over Austria.

This makes them Germany's first team and athletes to qualify for Pyeongchang 2018.

mds/pfd (SID,dpa)