Winger Louis Rees-Zammit scored a hat-trick of tries as Wales beat Georgia 43-19 to secure first place in World Cup Pool C on Saturday and a quarter-final against Argentina or Japan.
Wales, who lost their last match against Georgia 11 months ago, went into halftime with a 17-7 lead after tries by prop Tomas Francis and fullback Liam Williams but then faced a spirited fightback from the Georgians.
They had crossed the Wales line before the interval through captain Merab Sharikadze and stunned the Welsh with successive tries after the hour mark from replacement prop Vano Karkadze and wing Davit Niniashvili.
Rees-Zammit and centre George North scored late tries to extend the Welsh lead.
Flyhalf Sam Costelow, a last-minute replacement for Gareth Anscombe who was injured in the warm-up, kicked 14 points for Wales.
Georgia finished fourth in the pool with no wins and one draw against Portugal despite spirited performances against all their opponents including Australia and Fiji.