OSAKA, Japan (AP) — Tonga got its win, captain Siale Piutau got a farewell try on his birthday, and the United States got nothing but a record-equaling 10th straight loss at the Rugby World Cup.

Tonga beat the United States 31-19 on Sunday to avoid finishing last in Pool C. Already eliminated, both teams sought desperately to end their tournaments with a victory and something to build on.

Tonga did it, although it made life tough for itself by throwing away at least five try-scoring chances at Hanazono Rugby Stadium.

Tonga did make four opportunities count with four tries. Center Piutau’s score with just under 20 minutes to go was crucial in giving his team breathing space at 24-12. The United States made it interesting when flanker Tony Lamborn pushed the ball up against the post padding in a late surge and it was 24-19 with just under three minutes to go.

Fullback Telusa Veainu, guilty of messing up at least two tries, sealed Tonga’s first win of this World Cup when he dived on a kick behind the U.S. defense in the last play of the game.

Piutau ended with a try and a win on his 34th birthday and in his last test for Tonga before retiring from international rugby. He was voted player of the match and took the final conversion for good measure as the Tongan team all lined up behind him. When he landed the kick, they smothered their captain with hugs.

“We wanted to finish with a bang,” Piutau said. “What better way to celebrate a birthday, not only get the win but also get the accolades as well ... Just grateful.”

The win also avoided a sixth straight loss at Rugby World Cups for Tonga, which would have been a national record and completely changed the feel of Piutau’s farewell party. Flanker Sione Kalamafoni was also retiring from Tonga duty and they were both making a record 12th appearance at the World Cup for their country.

Coach Toutai Kefu described it as an “up and down” game which ultimately came right.

Before kickoff in Osaka, the U.S. and Tongan players stood in silence with heads bowed in a moment’s silence for those affected by Typhoon Hagibis. The powerful typhoon ripped through parts of Japan’s eastern Pacific coast on Saturday, bringing damaging winds, torrential rain and flooding, and leaving at least 19 people dead and more than a dozen missing.

The game in Osaka kicked off under gloomy skies but the sun broke through in the second half.

Tonga scored one try in the first half to lead 7-0 through a close-range barge from loosehead prop Sigfried Fisi’ihoi. They should have had another four in that first 40.

Two early breaks by scrumhalf Sonatane Takulua to within a few meters went begging. Veainu ruined a third chance inside the first 13 minutes when his pass went astray with a two-man overlap.

The U.S., clinging on in the opening spell, turned the tide with two tries in four minutes from replacement back Mike Te’o, who was on early at right wing for injured captain Blaine Scully.

Teo’s first was created by a one-hand offload from No. 8 Cam Dolan. His second came from a big overlap on the right and an over-the-top pass by fullback Mike Hooley. The U.S. snapped up both chances.

The Americans somehow led 12-7 at halftime despite conceding twice as many meters as the Tongans and missing 31 tackles. A first win at the World Cup since 2011 seemed on.

The U.S. was also pouring on the pressure at 12-10 in the second half when the ball was lost a meter from Tonga’s line.

Veainu, who wasted yet another open tryline in the opening skirmishes of the second half, had much to make up. He scooped up the loose ball, kicked way downfield, and led the chase. The Americans were all up in attack and exposed.

Center Malietoa Hingano chased alongside Veainu and picked up the pieces to run in the Tongans’ second try, complete with a soaring dive.

It was the crucial moment and a “14-point swing” on the scoreboard, U.S. coach Gary Gold said.

“That’s what the game comes down to,” Gold said. “Yeah, it was lost opportunities and I’m disappointed but also incredibly proud of this team.”

He was proud of the effort and the commitment, Gold said.

That was underlined when the U.S. forwards had crack after crack at the Tongan line in the dying minutes and Lamborn forced the ball up against the goalpost to get the Americans back in the contest.

Veainu shut down any chance.

The U.S. has now lost 10 straight at the World Cup to match its previous worst run from 1987-2003. They’ve gone through two entire World Cups without a win.

Tough for Scully to take any positives from Japan 2019.

“It’s probably pretty raw still,” the U.S. captain said. “If it showed anything, it shows how bloody hard it is to win a game at the Rugby World Cup.”