Sam Davies got Wales ‘out of jail’ with a late winner that was barely deserved after another two-faced display.

The young fly-half stepped off the bench for only his second cap but showed the nerves of a seasoned Test veteran as he stroked over a drop goal with just eight seconds remaining.

Ultimately it was a second victory in a row, but even head coach Rob Howley was forced to admit it was hardly justified and the manner of the win hardly raised spirits inside the Principality Stadium with the prospect of a “wounded animal” in South Africa looming next week.

Head coach Rob Howley said: “It was a disappointing performance and a relief to win. Japan were the better side and deserved to win. They must be disappointed that they haven’t because we used our get out of jail card at the end.

Japan were dejected at the final whistle (Getty)

“Sam Davies showed great composure to kick that drop goal at the end. He deserves all the accolades. It’s a win but we all felt as though it was a loss.”

For a time in the second half, this felt like the Brighton Community Stadium as Japan showed the same spirit of adventure as last year’s historic World Cup victory over the Springboks.

Only five of the Brave Blossoms from that win remain as Japan rebuilds but the new crop lived up to their nickname as they rallied time and again.

Howley said: “Japan’s kicking game put us under pressure because we lost the aerial battle. But we fuelled Japan’s enthusiasm and energy and their counter-attack with turn-overs that gifted them 14 points. It’s a concern to concede another 30 points, especially as many of them were from our own mistakes when we had the ball.”

Jamie Roberts scored on his return to the side (Getty)

Wales remain caught between which type of game to play but failed once again to provide a convincing argument they can beat South Africa, who head to Cardiff from a shock defeat in Italy.

Howley said: “We won 12-6 the last time we played them here, our players know that and so do theirs. We can take confidence from that but it’s a wounded animal heading to the Principality Stadium. The conditions under the roof will not be the same as in Florence for Italy’s win.”

Japan’s Yu Tamura kicked two early penalties, the second after Liam Williams cynically blocked Akihito Yamada that earned the full-back an early yellow card.

When Wales kept the game simple, boasting 65 per cent possession in the first-half, this game looked a stroll in the park as they bullied opponents. Dan Lydiate claimed his first Wales try, in his 59th Test, from Gareth Anscombe’s well-timed pass.

Alex Cuthbert should have followed but knocked on with the line at his mercy but Jamie Roberts, eager to impress after he was axed last week, drove over from close range.

At 14-6, the expectancy was upon Wales to kick-on but their rashness in over-playing cost them dearly. Anscombe ill-judged pass was picked up by Akhito Yamada inside the Japanese half and the wing raced clear to score.

Warburton scored for Wales (Getty)

Wales, struggling for confidence, failed to land the telling blow, guilty of allowing Japan to land a counter-punch to every score.

Alun Wyn Jones galloped through to hand captain Warburton an easy finish. It was simple but effective, yet within minutes, Japan had hit back through Kenki Fukuoka following a delightful pass by Tamura, who kicked the conversion from the touchline.

Wales were starting to panic and it was left to the boot of Halfpenny to nudge them ahead only for Japan’s wonderful No8 Amanaki Mafi, named man of the match, to loop a pass to Amanaki Lotoahea who juggled the ball before stepping past Williams to score.

Tamura’s conversion levelled the scores on 74 minutes before Davies snatched victory after Cuthbert went close.

Wales: L Williams; L Halfpenny, J Davies, J Roberts, A Cuthbert; G Anscombe (S Davies, 67), L Williams (G Davies, 50); N Smith (R Gill, 67), S Baldwin, S Lee (S Andrews, 67), C Hill (J Ball, 62), AW Jones, D Lydiate, J King, S Warburton (capt).

Japan: K Matsushima; A Yamada, T Lafaele, H Tatekawa (capt), K Fukuoka; Y Tamura (A Lotoahea, 33-40), F Tanaka; S Nakatani, S Horie, K Kensuke, K Kajikawa, S Anise, M Ilaua, A Mafi, S Nunomaki.

Referee: Marius van der Westhuizen (South Africa)

Attendance: 73,969