Josh Adams scored his fifth try of the Rugby World Cup as Wales beat Uruguay 35-13 at Kumamoto Stadium to set up a quarter-final against France.
Warren Gatland's side made hard work of sealing top spot in Pool D, but scored five tries to ensure they will face Les Bleus at Oita Stadium next Sunday, while Australia will meet England at the same venue 24 hours earlier.
Nicky Smith scored the only five-pointer of the first half and Adams become the outright leading try-scorer in the tournament after the break, with Tomos Williams and Gareth Davies also crossing after Wales were awarded a penalty try.
Uruguay were magnificent in defence as they bowed out with a spirited performance, German Kessler scoring their only try and Felipe Berchesi notching eight points with the boot.
Hallam Amos had three tries ruled out, but Wales made it four wins out of four to finish three points clear of the Wallabies despite being a long way from their best, Halfpenny converting four times in a man-of-the-match display.
Wales were disjointed in the opening stages but were eventually rewarded for applying huge pressure when prop Smith breached a resolute Uruguay defence, powering over from close range after 16 minutes.
Berchesi reduced the deficit to four points with a fine strike from the tee after Halfpenny converted Smith's score, and Amos was denied Wales' second try due to a forward pass from Hadleigh Parkes.
Handling errors prevented the Six Nations champions from getting into a rhythm and a second Berchesi penalty made it 7-6 at the break.
The clinical in-form Adams gave Wales breathing space when he took an inviting pass from Rhys Patchell to finish in the corner, Halfpenny expertly nailing a difficult conversion.
Amos had another score disallowed, again for a forward pass from Parkes, but referee Angus Gardner awarded Wales a penalty try when Uruguay were unable to legally stop a driving maul after Santiago Civetta was sin-binned.
Kessler had a moment to remember when he dived over with a pick-and-go before Williams picked up a loose ball to grab the bonus-point try, with Halfpenny converting superbly.
Amos was frustrated again when he lost control as he went to touch down, but Davies raced away long after the clock had turned red to go under the posts and Halfpenny converted, leaving the scoreline looking harsh on Uruguay.