Brazil's Italo Ferreira led his country to their first team gold since 2000 at the World Surfing Games in Miyazaki after sealing the individual men's title with an audacious full rotation aerial which earned a perfect 10-point score.
Ferreira's inspirational finish was all the more remarkable for the fact that he nearly missed the International Surfing Association's (ISA) flagship event – which for the first time involves Olympic qualifying places – because his passport was stolen just days before leaving for Japan.
He was able to get a new passport, fly to Miyazaki and make it to his first heat of the event with only eight minutes remaining – subsequently winning the heat.
Brazil finished with two other individual medals overall, as Gabriel Medina took the bronze in the men's division to add to the earlier silver won in the women's division by Silvana Lima.
The men's team silver went to the United States while defending champions and hosts Japan had to settle for bronze.
Peru won the copper medal, awarded in surfing for fourth place.
"That was a super cool contest," said Ferreira.
"I want to congratulate every surfer and country here.
"I am so tired, that was a lot of heats with a lot of emotional moments.
"I just tried to show my best surfing."
The men's grand final featured the world's top talent going for broke in vastly improved conditions at Kisakihama Beach after a passing typhoon had brought strong winds and rain for yesterday's competition.
The final ended in a flurry of manoeuvres that shook up the podium places.
Medina and Kolohe Andino both completed aerials in the last minute, with Andino getting the better of the exchange with 9.43 points to beat the Brazilian to silver.
Japan's Shun Murakami finished with the copper medal for the second consecutive year.
Earlier in the morning, Murakami had defeated Indonesia's Rio Waida in repechage round 10, making him the highest finishing Asian surfer in the event and therefore capturing provisional qualification for surfing's Olympic debut at Tokyo 2020.
Murakami and Waida embraced on the beach in an amazing gesture of sportsmanship, despite Olympic qualification slipping through the Indonesian's fingers.
"I was not thinking about the Olympic qualification, just surfing in the moment and fighting in that heat," said Murakami.
"I am looking forward to competing in Tokyo 2020, it would be great if I can hold onto my spot."
Repechage round 10 had started off with a surprise as Brazil's Filipe Toledo had to withdraw due to injury.
With Brazil in the lead heading into the final day, the injury could have had significant ramifications in the team rankings.
There was a setback for the US as Kelly Slater competed in the main event final but then fell into the repechage final, from which he was not able to advance.
"Today is a very special day for the history of surfing," said ISA President Fernando Aguerre.
"For the first time, every nation brought their surfing dream teams and for the first time an ISA World Surfing Games is a qualifier for the Olympic Games.
"The ISA will be back in Japan in less than a year, for the arrival of surfing at the world's greatest sporting stage, the Tokyo Olympic Games."
Tokyo 2020 sports director Koji Murofushi said: "Tokyo 2020 is delighted with the success of the 2019 ISA World Surfing Games in Miyazaki this week.
"The event, held in this very popular surf destination in Japan, offered a glimpse of how spectacular Olympic surfing will be next year.
"Across the whole week, there was an amazing energy along Miyazaki's beaches as passionate, youthful fans cheered on the best world-class surfers from around the world as they sought Olympic qualification.
"We were also very impressed with the Surfing Festival that was held on the first weekend – with great music and culture that created a fantastic celebratory atmosphere.
"Our Tokyo 2020 teams at the ISA World Surfing Games were able to learn a lot from this competition experience, which will ensure that the Olympic Games are also a great success next year."