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.
South Africa skipper Temba Bavuma said the team would look to return to the venue -- the world's biggest cricket stadium with a capacity of 132,000 -- in the final on November 19.
"We would want to play here (in Ahmedabad) again, in front of a full capacity crowd, and it will be a different experience playing in front of a hundred thousand fans," said Bavuma.
"Before that, we have Australia. We will enjoy today and from tomorrow, we will start training our minds for that clash."
Playing for pride, Afghanistan's spinners checked South Africa's strong start of 64-0 after Mujeeb Ur Rahman dismissed 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.
"Obviously my leg is sore. Don't know to what extent but it is going to have to be fine, at least in my eyes," he said.
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.
- 'Lots of learnings' -
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.
"We played big teams and we fought till the last moment, even if we lost," said Shahidi.
"Even the Australia game was in our hands but it was shocking the way (Glenn) Maxwell batted. I was very shocked, but there were lots of learnings too."
On Tuesday, Maxwell took the game away from Afghanistan from 91-7 to chase down 292 with the Australian unbeaten on 201 as he played through cramps and back spasms.