Japan came within 20 seconds Saturday of once again shocking the rugby world.

Despite missing a plethora of players through injury and self-imposed exile, the Brave Blossoms pushed Wales all the way before a last-gasp drop goal from Sam Davies saw the hosts win 33-30 in front of 73,969 at the Principality Stadium.

With the forwards working tirelessly — none more so than man-of-the-match Amanaki Lelei Mafi — Japan frustrated its opponent and scored three good tries to put itself in a position to repeat its heroics of Rugby World Cup 2015, when South Africa was among its three scalps.

But Davies' cool head and accurate left boot ensured it was Wales which left the field with the win on the scoreboard, leaving Japan fans to merely claim a moral victory.

"(I'm) a little bit disappointed, I guess, because it was a big test match for our team," said Japan coach Jamie Joseph.

"We put ourselves in a position to be able to win the match, then coming away I guess in the last 20 seconds and losing the match was a little bit bitter. But having said that, I'm really proud of the players. A lot of these guys haven't actually played at this level, certainly haven't played in front of 70-odd thousand people. But what you guys witnessed there was belief in a game plan, belief in each other, and some of those old attributes are often lost in professional footie, so I'm really proud about that."

The Welsh too admitted that the result could and perhaps should have gone the other way.

"I thought Japan were the better team today and deserved to win," said Wales coach Rob Howley. "Whilst we come away with a win, it certainly felt like a loss. Japan deserve the accolades they will get. They were the better team, but we got past the winning post."

With Akihito Yamada prominent early on, Japan started well and two penalties from Yu Tamura saw the Brave Blossoms go 6-0 up.

Wales hit back, however, despite Liam Williams being sent to the sin bin, and Dan Lydiate made the most of a good build-up to cross the chalk in the 10th minute.

Leigh Halfpenny kicked the conversion from the right-hand touchline to make it 7-6 and then added the extras to a try by Jamie Roberts 12 minutes later as Welsh dominance up front started to be rewarded.

Despite being on the back foot, Japan stayed in the game and a great defensive read from Yamada saw the flying wing pick up a loose pass and sprint away for a try in the 37th minute.

Timothy Lafaele banged over the conversion with Tamura temporarily off the field for a head injury assessment as the teams went into the break with one point between them at 14-13.

A poor restart from Tamura allowed Wales to stretch its lead two minutes into the second half as Halfpenny kicked an easy penalty.

And the wing was again on target in the 52nd minute when he added the extras to a try from Sam Warburton, created by Alun Wyn Jones.

Japan struck back immediately, however, when some superb hands from the forwards and backs allowed Kenki Fukuoka to go over in the corner.

"Our will to get it done was beautifully executed," Fukuoka said. "That try had a great feel to it.

"Being able to put our opponents' back to the wall while on the road was a lesson for us. It feels like this team has grown up."

Tamura slotted the conversion from the touchline to make it 24-20 and then exchanged penalties with Halfpenny to ensure four points separated the teams with 18 minutes remaining.

A third penalty from Halfpenny gave Wales a bit of breathing space and finally saw the crowd break out of its shell-shocked silence.

But Japan struck back when Mafi did superbly to put away his former Hanazono University teammate Amanaki Lotoahea for a try in the 73rd minute.

Tamura's conversion brought the teams level, but any hopes of a famous win or draw were dashed when Davies kept his head and bisected the poles at the death.

"I think a fair score would've been a draw," said Joseph. "I think both teams had their times in the game, and I think we surprised the Welsh team and the Welsh fans. I think we did that really well, and I think the players believed in the plan, and came up short, but I think we're on our way."

It was a view shared by Howley.

"In fairness to Japan, they had the skill, energy, enthusiasm and were unfortunate not to win the game," he said.