Second-half indiscipline ruined an often sparkling effort from Japan's Brave Blossoms in a 39-31 loss to Ireland on Saturday in Dublin.

After an evenly matched and entertaining first half at Aviva Stadium, Japan were completely undone by repeated penalties that negated the visitors' ability to score electric tries and allowed Ireland to avenge their 19-12 2019 World Cup loss to Japan.

Captain Michael Leitch, Timothy Lafaele, Siosaia Fifita and Naoto Saito each scored tries for Japan. After Saito's 57th-minute score — thanks to some wizardry from Yu Tamura — the fly-half's conversion made it a two-point game, but from that instance on Ireland settled down and dominated.

"We deserve to be disappointed," Leitch said. "We played well and we couldn't execute in the end. The game was in the balance and we couldn't score. I'm proud of the effort but we've got to keep working on our game."

"We're not the bigger side but we've got the skill sets, we're fit and we can play this game. It was a good test but we want to win these test matches."

Tamura opened the scoring with a fourth-minute penalty that Ireland answered with Chris Farrell's try four minutes later. Japan hit back in the 11th minute with Leitch scoring from a rolling maul. Tamura converted to give Japan a 10-7 lead.

Japan had a second try waved off for a forward pass, with Ireland instead taking the lead on a 26th-minute Stuart McCloskey try, when the Brave Blossoms defense seemed to fall asleep for about 45 seconds.

The visitors completely missed a kick from Joey Carbery that the Ireland fly-half recovered. And before Japan could blink, Ireland had the ball in numbers down the left flank for a 12-10 lead.

Lafaele, however, crossed in the 36th minute. After a stolen lineout, and with the advantage, Tamura's cross-field kick found Fifita, who broke free before passing back to Lafaele to cross the whitewash.

Ireland had the last word of the half, though, as one pick-and-go after another ended with Finlay Bealham crossing and Carbery adding the extras to send the hosts into the half with a 19-17 lead.

The high energy and fast tempo carried over into the second half as Japan scored the first try. Tamura took the ball from the breakdown near the touchline and rounded the defense before kicking it into Fifita's path.

Ireland this time answered with two quick tries. The Irish found they could spread Japan wide with quick passes and punch through between tacklers. Josh van der Flier scored via this route in the 49th-minute. Jacob Stockdale repeated that in the 52nd after a penalty on fullback Kotaro Matsushima, who came out hurt.

Two minutes later, when Japan seemed dead and buried, Ireland's concentration lapsed and some superb play from Semisi Masirewa opened the door for Saito to sprint in for Japan's final try.

Tamura converted to shrink Ireland's lead to 33-31, but Carbery took advantage of Japan's mistakes to add two penalties before the final hooter.

"Japan are a quality side and they're going to trouble whoever they play. We're delighted to get the win," said Ireland's man of the match, van der Flier. "We saw how good they were in the World Cup. It took a top quality effort in the second half for us to get the win."