KUMAMOTO, Japan -- Wales were made to work hard for victory against Uruguay, but they prevailed with a bonus-point 35-13 win in Kumamoto on Sunday to top Pool D and set up a quarterfinal with three-times finalists France.
Wales clung to an eight-point lead with seven minutes to play, when a strong carry by Leigh Halfpenny scattered the Uruguayan defence and opened a hole for Tomos Williams to settle the matter with the bonus-point try.
Wales also scored tries from Nicky Smith, Josh Adams, Gareth Davies and a penalty try, but coach Warren Gatland was a picture of discontent for much of the evening.
His team were denied four tries, including two from forward passes, and committed a slew of handling errors on a perfect night for rugby.
"We know we have to do a lot better than that, but we have to be happy that we came away with a bonus-point win," said flanker Justin Tipuric, who led the side for the first time in place of regular rested skipper Alun Wyn Jones.
"You have to give Uruguay credit. They didn't stop from the beginning to the end and they're a tough bunch of boys."
Uruguay bowed out of the World Cup with huge satisfaction having earned plenty of respect from tier-one nations and also upset Pacific power Fiji earlier in the tournament.
"There were areas where we were able to play how we wanted and we were also able to shock Wales," Uruguay coach Esteban Meneses said.
"We were able to show how we have developed Uruguayan rugby."
Wales went into match with 13 changes and a patched-up backline, with Dan Biggar sidelined after his second head knock of the tournament, and flanker Justin Tipuric standing in as captain for the rested Alun Wyn Jones.
Wales dominated possession in the early exchanges but their attacking raids were stopped by dogged Uruguayan tackling and a slew of handling errors.
Flanker Aaron Shingler broke through on the right wing to plant the ball by the flag in the 11th minute, but the try was disallowed as he was well outside the touch line.
With their try-line under siege, Uruguay's resistance broke in the 17th minute as prop Nicky Smith was driven over the line.
Uruguay responded well and almost hit back with their own try minutes later, but a long pass from Felipe Berchesi drifted forward to winger Leandro Leivas on penalty advantage; Berchesi kicked for three points instead.
Wales were denied a second try in the 25th minute, with Hadleigh Parkes putting winger Hallam Amos over with a forward pass.
Not even a chorus of singing from Welsh fans could help Gatland's side as they turned over the ball deep in Uruguay's 22 and gave Berchesi a second penalty in front of the posts.
It was all back-slapping and smiles among the Uruguayans as they jogged off with only a 7-6 deficit at halftime.
Wales rebooted after the break, testing Uruguay with the high ball.
Bradley Davies was bundled back over the line near the posts by the desperate Uruguayans but the big lock's strong carry created an overlap out wide and an unmarked Josh Adams cantered over at the left corner after a long pass from Rhys Patchell.
Wales were threatening to break the game open, but the scrappy play returned as Parkes' horror night continued.
The inside centre blew a third try for Wales by putting Amos over the line with another forward pass.
A yellow card to Uruguay flanker Santiago Civetta eased the pressure and paved the way for a penalty try as Wales rumbled a maul toward the line.
Yet Uruguay rallied brilliantly, with hooker German Kessler diving over from in close to throw a scare through the Welsh in the 71st minute.
Wales rose to the challenge as Williams grabbed the bonus-point try but they were left red-faced minutes later when Amos spurned another try -- the winger failing to plant the ball correctly when doing a flamboyant swan dive.
In a madcap finish, Gareth Davies ensured Wales finished on a high note as he burned away from the Uruguayan defenders after a turnover to cross under the posts.