Wales player Bradley Davies tackles Samoa's Jeremy Sua. REUTERS/Nigel Marple
The Welsh were forced to defend for their lives after winger Shane Williams had scored their only try 13 minutes from time but held on to give themselves every chance of progressing from Pool D, which also includes Fiji, Namibia and South Africa.
Samoa, who were aiming for a third World Cup win over the Welsh after 1991 and 1999 triumphs, took a 10-6 lead on the stroke of halftime when prop Anthony Perenise pirouetted his way through three tacklers to cross the line and Paul Williams converted.
Wales, who narrowly lost their opener to South Africa, tackled themselves to a standstill, however, and the Williams try combined with two penalties apiece for James Hook and Rhys Priestland proved enough for victory.