Japan withstood a spirited fight from Portugal on Saturday, grinding out a 38-25 victory in the first-ever test match between the two countries.

Debutant Shogo Nakano was among four try scorers for the tourists, who earned 18 points off the steady boot of flyhalf Rikiya Matsuda at the Estadio Cidade de Coimbra.

Coming off a humbling 60-5 loss to Ireland a week ago, the world No. 10 Brave Blossoms held the upper hand for most of the contest against Portugal but gave away too many penalties for their own liking.

"It's an area we need to get better," head coach Jamie Joseph said. "But when we had control of the game I thought we played some really good rugby."

Japan took the lead when Siosaia Fifita crossed after just four minutes, finishing a clever attacking movement sparked by Matsuda's chip ahead from a lineout.

After getting on the board with a penalty, the 19th-ranked Portuguese went ahead 8-5 in the 23rd minute when flyhalf Jeronimo Portela sent center Jose Lima into space for a try.

Three straight Matsuda penalties put Japan back in the driver's seat, and they took a 21-11 lead into the break after the 24-year-old Nakano burst through the line for his maiden try on the stroke of halftime.

Portugal capitalized on Michael Leitch's sin-binning early in the second half, mauling their way to a try and a 21-18 deficit after scrumhalf Samuel Marques added the extras.

Jamie Joseph's men reasserted control after front rower Asaeli Ai Valu surged toward the line off a stolen lineout, getting tackled just short but enabling Kazuki Himeno to bulldoze over from a meter out.

A converted try brought Portugal back within striking distance at 28-25 midway through the half, and an upset loomed after Japan had Isileli Nakajima sin-binned with four minutes left and their lead at 31-25.

With the hosts advancing in search of a match-winner after the buzzer, Japan fullback Ryohei Yamanaka pounced for an intercept and sealed the victory with a sprint from inside his own half.

"We had two yellow cards and we were fighting with 14 people for 20 minutes, and that was tough in a game like this," Himeno said.

The result was Japan's first test win since beating Scotland 28-21 on home soil in October 2019 en route to the Rugby World Cup quarterfinals. They will face the Scots in the finale of their European tour at Murrayfield on Saturday.