Japan's Ayumu Hirano soared to gold at the men's snowboard halfpipe final on Friday at the Beijing Games, while a tearful Shaun White said he was thankful for his final run despite just missing out on the podium in his fifth and last Olympics.

Hirano, who won silver at the Pyeongchang 2018 and Sochi Games 2014, went into his third and final run in second place, under pressure to top Australian Scotty James who threw down a double cork 1440 with a tail grab on his second run.

Seemingly not phased by the pressure, Hirano dropped into his final run, catching more than five metres of air to land a triple cork, an advanced trick the Japanese boarder introduced for the first time ever at competitions in December.

Hirano's third run earned him the top score of 96, forcing James to settle for silver with 92.50. Swiss Jan Scherrer, 27, won bronze with 87.25 followed by American White on 85.00.

"It hasn't sunk in yet but finally one of my childhood dreams has come true," said the 23-year-old Hirano, who had dreamt of winning an Olympic gold medal since he started snowboarding aged four.

He spent six months intensely training for the triple cork, a dangerous trick consisting of three head-over-heels flips and a twist while grabbing the board. Hirano said he perfected it after he drilled it up to 60 times a day for six months.

Ayumu Hirano's stunning display earned a deserved gold medal on the halfpipe

Three-time gold medallist White, who has said this would be his final Olympics and his last time competing professionally, finished in fourth place after clipping the lip of the halfpipe on his third run and sliding down the wall feet-first.

Removing his helmet to hear the applause of the crowd one last time, White cruised slowly down to the finish to await his final score. With tears streaming down his face, the 35-year-old hugged his fellow competitors, many of whom call him their hero.

Wiping away tears, White repeatedly told reporters how "thankful" he was for his career and legacy in the sport.

"I'm not sad about today. It's about the legacy and the career I'm leaving behind," he said.

"As hard as it is to say goodbye I'm happy to have inspired the next generation," White added, saying tricks like Hirano's were pushing the sport to the next level.

Australia's James, who won bronze at the Pyeongchang Games, said he felt proud to represent his country and battle it out against Hirano until the final run.

"It's been insane to become a rival (of Shaun's) over the years. I looked up to him," James said as White, choking back tears, hugged him from behind.

The often sparsely filled stands at the Genting Snow Park were packed with supporters for the final and the area near the finish line was filled with American and Japanese team mates waving their national flags.

The whole crowd roared when White finished his final run.