Defending champions South Africa advanced to the World Cup quarter-finals by winning Pool D with a 100 per cent record after beating Samoa in a titanic tussle at North Harbour Stadium in Albany.
All of South Africa's points came in the first half, but despite a mighty effort, Samoa, who were reduced to 14 men when Paul Williams was sent off late on, were unable to keep their last-eight hopes alive.
Bryan Habana scored a ninth-minute try, Morne Steyn added the conversion and a penalty and Frans Steyn kicked a penalty from his own half for the Springboks, who are set to play in the runners-up in Pool C in Wellington next Sunday.
George Stowers' second-half try was not enough for Samoa, who had full-back Williams sent off after 70 minutes for punching Heinrich Brussow.
South Africa also finished the match with 14 men after captain John Smit, on as a replacement, was shown a yellow card for kicking the ball away.
Samoa's failure to get a losing bonus point means they are set to finish third in the pool and Wales should advance as runners-up, barring a major shock against Fiji on Sunday.
Entering the match, Samoa needed at least a losing bonus point and a Fiji win in Wellington to have any chance of progressing, but the Springboks were determined to find their form for the knockout stages in their own uncompromising style.
It was a brutally physical contest and there were a couple of heated off-the-ball exchanges in an absorbing 80 minutes even before cards were shown.
After Morne Steyn missed a drop-goal attempt and Frans Steyn hit the crossbar with a long-range penalty, South Africa broke through.
Habana went over in the corner for his 40th Test try and his 10th in 10 World Cup appearances. Morne Steyn converted.
Frans Steyn kicked a penalty from almost 60metres and Morne Steyn added one from 40m before the centre missed a 62m effort.
A blindside burst by Kahn Fotuali'i almost set up a Samoa score in first-half stoppage time, but Seilala Mapusua's pass went to ground.
A hobbling Habana was replaced by Francois Hougaard after 47 minutes before Samoa touched down.
With Danie Rossouw and Hougaard off the field, both forced into the blood bin, Samoa spread the ball wide and a pass to Williams went to ground.
But it was quickly recycled and Stowers barged over.
Morne Steyn missed a penalty before the Springboks survived after wing David Lemi burst into the 22, only to be penalised for not releasing when it appeared he had not been held in the tackle.
Samoa's chances suffered a blow after Williams was shown a red card for lashing out at Brussow after the South Africa flanker had been held back at a ruck.
Brussow was perhaps fortunate to avoid a spell in the sin-bin, but South Africa also ended the game with 14 men when captain Smit, on as a replacement hooker, was shown a yellow card after 71 minutes for kicking the ball away.