Cape Town - A last-minute drop-goal from replacement flyhalf Sam Davies helped save Welsh blushes on Saturday as they edged Japan 33-30 in Cardiff.
It looked like the Brave Blossoms had snatched a draw when Yu Tamura converted Amanaki Lotoahea's 74th minute try, but Wales went down the other end of the field, with Davies showing composure to slot the three points.
Wales will now go into their game against South Africa at least with a win under their belt but their performance left a lot to be desired.
They led 14-13 at the turnaround but handed seven points to Japan late in the half to give the Brave Blossoms hope of a shock victory. Japan do deserve credit though as they remained in the match almost throughout.
Tamura put Japan 0-6 in front by nine minutes, via two penalties, but Wales then moved ahead thanks to Dan Lydiate crossing wide out. Leigh Halfpenny made no mistake with the conversion as it had become 7-6.
The majority of those points came whilst Wales full-back Liam Williams was in the sin-bin for blocking so the hosts had to be pleased.
With Williams back on the field, Wales set about extending their lead and did just that on 23 minutes when Jamie Roberts went over after a strong initial carry from Jonathan Davies. Halfpenny made it 14-6.
That would've been a somewhat pleasing half-time scoreline for Wales after such a sluggish start but when Gareth Anscombe's offload was gathered by Akihito Yamada, who set off for the line from his own half, just one point separated the two teams in the dressing rooms.
Halfpenny made it 17-13 two minutes after the break with a penalty and 10 minutes later the lead was up to 11 points when Sam Warburton crossed after a bust from Alun-Wyn Jones. Japan's hopes looked to have been ended.
But two minutes later Kenki Fukuoka finished well on the left wing and with Tamura's touchine conversion, it was now 24-20 to Wales.
Halfpenny made it 27-20 on the hour mark before Tamura and the Welsh wing then traded efforts for 30-23 with just 10 minutes to play.
Then came the levelling score from the Brave Blossoms as replacement Lotoahea's try was converted by Tamura, with Wales needing to dig deep to prevail, which they did via Davies' cool drop-goal with seconds to play.