Defending champions South Africa saw off Tonga 49-18 to pick up a bonus-point win in Marseille which moved them temporarily top of Rugby World Cup Pool B.
Ireland could have been sure of a quarter-final place before their final pool match against Scotland had the Springboks failed to beat Tonga, who had lost both previous games.
Andy Farrell’s men, though, can guarantee top spot if they avoid defeat by Scotland, whose own qualification hopes are slim.
Tonga got the first points on the board at the Stade Velodrome through an early penalty from William Havili.
But South Africa were soon in front when scrum-half Cobus Reinach tapped up a quick penalty before sprinting over in the corner.
The Springboks further extended their lead in the 20th minute when the ball bounced off Vincent Koch’s shoulder and straight to Canan Moodie, who darted under the posts.
Makazole Mapimpi went off for a head-injury assessment after being caught by Augustine Pulu as they ducked into a tackle. English referee Luke Pearce and the TMO agreed it was not a yellow-card offense by the Tongan, who was down on his knees at point of contact.
South Africa, edged out 13-8 by Ireland at the Stade de France, scored again through Deon Fourie on the half-hour mark following a driving maul from a lineout before Tonga had a try on the board when captain Ben Tameifuna powered over to reduce the deficit to 21-8 at half-time.
The Springboks secured a bonus-point try early in the second half when replacement Jesse Kriel pushed over and the TMO then ruled against a yellow card to Eben Etzebeth for a collision with Tonga full-back Salesi Piutau.
Tonga responded again as winger Fine Inisi touched down in the corner, only for Willie Le Roux to go over down the left and South Africa replacement Marco van Staden added another try following a well-worked swift counter.
Coventry fly-half Pat Pellegrini produced a memorable moment as he chased down his own kick to score under the posts before Kwagga Smith dived over for South Africa’s seventh try in added time.
South Africa v Tonga - Match Stats
South Africa (21) 49
Try: Reinach (5'), Moodie (20'), Fourie (32'), Kriel (49'), Le Roux (58'), Van Staden (63'), Smith (80'+1)
Conversion: Pollard (6', 21', 33', 51'), Libbok (59', 65', 80'+2)
Tonga (8) 18
Try: Tameifuna (38'), Inisi (53'), Pellegrini (73')
Penalty: Havili (3')
Man of the match: Deon Fourie (South Africa)