The Cook Islands ultimately posted a first World Cup victory at the sixth attempt, yet they had to hang on despite building a 22-4 lead just after half-time.
Centre Keith Lulia ran the show for his team, scoring a first-half try, while Isaac John, Daniel Fepuleai, Dominique Peyroux and Jonathon Ford also touched down, with Chris Taripo kicking four goals.
Wales, though, threatened a second-half revival when Lloyd White, Christiaan Roets (two) and Rhodri Lloyd claimed tries following Rob Massam's first-half score, while White and Danny Jones landed one goal apiece, but it proved too little too late.
Wales had exited the tournament with indecent haste, failing to recover from their Millennium Stadium defeat against Italy a fortnight ago before being beaten by the United States in Wrexham and conceding 56 points across both games.
They had plenty of incentive to bow out on a high, though, with Jordan James equalling the Wales cap record of 30 appearances before retiring from the international game, while prop Neil Budworth also bade Wales colours farewell.
But it took them until 10 minutes into the second period before they could produce the quality of rugby coach Iestyn Harris would have demanded, yet they were always chasing the game.
The Cook Islands dominated early territory, and they deservedly went ahead after eight minutes when hooker Fepuleai powered over from close range.
Taripo added the extras, and Wales could have few complaints, but they stirred into life six minutes later as full-back Elliot Kear made a telling entry into the line, found Rhys Evans in support and Massam finished off.
It was a strong response by the home team, which knocked the Cook Islands out of their initial rhythm, but Lulia had developed into the game's dominant figure.
His initial break nine minutes before half-time caused panic stations in the Wales defence, and although Lulia was hauled down just short of the line, he was not to be denied in the next play.
Wales simply ran out of numbers and Lulia crossed unopposed to give the Cook Islands an advantage that their slicker handling and support work undoubtedly warranted.
In contrast to Wales, who lacked composure in the final third, the Cook Islands proved emphatic finishers, and Penrith Panthers player John skipped his way across for try number three.
Taripo's goal left Wales 16-4 adrift at the break and staring at a World Cup whitewash.
And there was no immediate sign of things improving after the restart, with Wales caught cold by their opponents' attacking verve that led to a try for Peyroux.
Taripo's third goal from four attempts left Wales trailing 22-4 and seemingly facing a damage-limitation exercise for the remainder of a game that had again seen them struggle.
But the hosts had either ideas, and they fought back through tries during an impressive eight-minute spell for White and Roets that breathed life into a contest the Cook Islands appeared to have control of.
And an exciting finish was cranked up another notch when Lloyd scored 14 minutes from time, with Jones' kick going over via an upright as Wales cut their deficit to just two points.
It raised the real prospect of an unlikely Wales win, but the Cook Islands responded with Ford's well-worked try that finally closed off any comeback route.
- Sports & Recreation