Rassie van der Dussen hit an unbeaten 76 to lead South Africa to a comfortable five-wicket win over Afghanistan in their last World Cup group game on Friday as their opponents were eliminated from the semi-final race.

Chasing 245 for victory, Van der Dussen steered the Proteas home with 15 balls to spare in a tune-up for their semi-final against Australia next week.

Azmatullah Omarzai hit an unbeaten 97 to guide Afghanistan to 244 all out in a match where they needed an unlikely 438-run win to make the last four.

New Zealand look all set to meet hosts India in the other semi-final unless Pakistan pull off a huge win against England on Saturday.

Playing for pride, Afghanistan’s spinners checked South Africa’s strong start of 64-0 after Mujeeb Ur Rahman dismissed skipper Temba Bavuma for 23 and fellow spinner Mohammad Nabi trapped Quinton de Kock lbw on 41.

Bavuma’s hamstring troubled him throughout the match while fielding and batting in a worrying sign ahead of their semi-final.

De Kock, who will quit one-day internationals when this World Cup is over, overtook New Zealand’s Rachin Ravindra (565) to reclaim his top spot in the tournament batting chart with 591 runs including four centuries.

The Proteas put their chase back on track in a third-wicket stand of 50 but leg-spinner Rashid Khan broke through with the wicket of Aiden Markram for 25.

South Africa looked in trouble when Rashid bowled Heinrich Klaasen for 10 but Van der Dussen stood firm to build partnerships including an unbeaten 65-run stand with Andile Phehlukwayo, who hit the winning six in an unbeaten 39.

Earlier Afghanistan slipped to 116-6 before Azmatullah hit his ODI best to lift the team to a competitive total.

South Africa fast bowler Gerald Coetzee took four wickets while spinner Keshav Maharaj returned impressive figures of 2-25.

De Kock played a key part with his six wicketkeeping dismissals to equal a World Cup record of Australia’s Adam Gilchrist (v Namibia - Potchefstroom, 2003) and Pakistan’s Sarfaraz Ahmed (v South Africa - Auckland, 2015).

Openers Rahmanullah Gurbaz and Ibrahim Zadran started aggressively before Maharaj struck with his first ball to have Gurbaz caught for 25.

Coetzee sent back Ibrahim in the next over to check the batting surge and Afghanistan slipped from 41-0 to 45-3 when Maharaj had skipper Hashmatullah Shahidi caught behind for two.

Afghanistan lost three more wickets to be in danger of getting bowled out in less than their quota of 50 overs but Azmatullah stood firm to play out the innings.

Afghanistan, led by Hashmatullah Shahidi, ended a strong campaign after they beat defending champions England, Pakistan, Sri Lanka and the Netherlands.