Wales secured as bonus point 28-8 win over Portugal thanks to a try in the final minute of the match.
Anything other than a bonus point win would have been deeply unsatisfactory and Wales were made to work for it.
Portugal missed an early opportunity to take the lead. Johnny Williams was penalised for going offside on the edge of his own 22. But scrum-half Samuel Marques missed a kick he really ought to be nailing.
Wales soon hit their straps and Louis Rees-Zammit regathered his own grubber in behind to finish his side's first real attack of the match brilliantly. Leigh Halfpenny knocked over the extras.
Portugal were finding gaps in Wales' defence though and would have scored a try were it not for a world class cover tackle from Taulupe Faletau in the 16th minute.
Wales couldn't really get their attack going against a stubborn defence and life was made harder from them in the 26th minute, when Johnny Williams was sent to the sin bin. The centre slapped a Portuguese offload away whilst on the floor and referee Karl Dickson had no hesitation.
Portugal got on the board in the 37th minute, when Mason Grady was penalised for a high tackle. Marques didn't miss this time from in front of the posts.
Upon his return, Williams thought he'd made amends for his previous indiscretion and barged his way over, but the replay showed he'd dropped the ball as he approached the line.
Wales had a penalty, though, and captain Dewi Lake ploughed over with a tap-and-go with the very next play. Halfpenny's conversion extended the lead.
Gatland's side were leading 14-3 at the break but their performance had been underwhelming.
Things continued in similar fashion for the first 15 minutes of the second half but eventually Portugal cracked. Jac Morgan, a late replacement for Tommy Reffell in the starting side, burrowed his way over from close range.
Welsh insdiscipline then gave their opponents easy access to the 22 and Portugal crossed for a try. A clever lineout move five metres out sent flanker Nicolas Martins over in the 62nd minute.
Gareth Davies thought he'd secured Wales' bonus point in the 75th minute when he finished off a Rees-Zammit break, only for the TMO to intervene after spotting some obstruction and the try was ruled out.
Portugal's Vincent Pinto was then shown a yellow card - which was later upgraded to a red - for raising his boot dangerously and catching Josh Adams in the face, in what could have been an ugly incident. Fortunately Adams didn't suffer any serious damage but Pinto headed to the naughty step.
Then, in the last play of the game, Taulupe Faletau picked up from the base of a scrum and crashed over from five metres out, finally sealing a bonus point win.
Wales: Leigh Halfpenny; Louis Rees-Zammit, Mason Grady, Johnny Williams, Rio Dyer; Gareth Anscombe, Tomos Williams; Nicky Smith, Dewi Lake (C), Dillon Lewis; Christ Tshiunza, Dafydd Jenkins; Dan Lydiate, Jac Morgan, Taulupe Faletau.
Reps: Ryan Elias, Corey Domachowski, Tomas Francis, Adam Beard, Taine Basham, Gareth Davies, Sam Costelow, Josh Adams.
Portugal: Nuno Sousa Guedes; Vincent Pinto, Jose Lima, Tomas Appleton (C), Rodrigo Marta; Jeronimo Portela, Samuel Marques; Francisco Fernandes, Mike Taylor, Anthony Alves; Martim Belo, Steevy Cerqueira; Joao Granate, Nicolas Martins, Rafael Simoes.
Reps: David Costa, Lionel Campergue, Diogo Hasse Ferreira, Thibault de Freitas, David Wallis, Pedro Lucas, Joris Moura, Raffaele Storti.