Calmness of Rassie van der Dussen and the fire of Gerald Coetzee helped South Africa overcome a spirited resistance from Afghanistan to carve out a five-wicket win in their last league game of the ICC World Cup 2023 in Ahmedabad on Friday.
Set a target of 245, South Africa, who are already assured of a place in semifinals, completed the task with Van der Dussen remaining unbeaten on 76 off 95 balls.
Andile Phehlukwayo was unbeaten on a 37-ball 39 after a match-winning partnership of 65 runs with Van der Dussen.
Earlier, pacer Coetzee took four wickets as Afghanistan were limited to 244 despite Azmatullah Omarzai's impressive 97. Omarzai's knock, however, helped the Afghans to recover from 116 for six.
The defeat notwithstanding, Afghanistan, who shocked defending champions England and Pakistan during a very promising campaign, would go home with their heads held high.
Continuing his good run in the tournament, Omarzai faced 107 balls while hitting seven fours and three sixes. However, he could not record his maiden ODI hundred after failing to score off the last three balls of the final over bowled by Kagiso Rabada.
On a pitch without any demons, South Africa started their chase confidently. But, as the match progressed, things didn't pan out the way South Africa would have liked them to.
In the end, they achieved it with 15 balls remaining after a mighty scrap.
The in-form Quinton de Kock (41 off 47 balls) made his intentions clear quite early with a four and a six off Mujeeb Ur Rahman, dancing down the track to pummel the seasoned bowler over mid-off.
The dashing left-handed batter, who went past Rachin Ravindra to become the leading scorer of this tournament, then pulled a Naveen-ul-Haq half-tracker over deep square leg for a maximum.
De Kock, however, could not go on to make a big one as he was adjudged trapped in front of the wicket by Mohammad Nabi, who chose to review after failing to convince the on-field umpire.
Looking to play a reverse sweep, De Kock missed and the ball hit the pads, prompting Nabi to go for a loud appeal. Afghanistan's move to review the decision was vindicated when the ball tracking showed that it was going to hit the leg stump.
De Kock, who had earlier in the day joined the likes of Adam Gilchrist and Sarfaraz Khan by taking six catches, struck two fours and three sixes.
Meanwhile, skipper Temba Bavuma's (23 off 28) poor run continued as he was shown the door by Mujeeb, who had the batter in all sorts of trouble with a back of a length delivery that hurried onto him.
Bavuma, who looked like he was struggling while fielding, seemed to battle cramps after he had come out to bat with an intention to spend some time in the middle following an underwhelming sequence of scores.
Aiden Markram (25 off 32) also gave his wicket away after getting a start while Heinrich Klaasen was dismissed by the wily Rashid Khan, a well-deserved reward for some excellent bowling, as South Africa slipped to 139 for four in the 28th over.
A 43-run partnership ensued before Nabi had David Miller (24 off 33) in a rather soft dismissal, leaving Van der Dussen to complete the job.
Earlier, Afghanistan were off to a steady start after their skipper Hashmatullah Shahidi opted to bat first, but South Africa meant business as they snared three wickets for four runs to leave their opponents in a spot of bother at 45 for three in the 11th over.
At that point, it seemed like the decision to bat first was backfiring even as Bavuma marshalled his resources well to keep South Africa ahead in the game.
But even before the Proteas could celebrate the first breakthrough they faced an anxious moment when pacer Lungi Ngidi went off the field after suffering what looked like an ankle or achilles issue.
Ngidi, however, returned to pick the wickets of Rahmat Shah and Nabi, who nicked one to De Kock after facing just three balls, leaving his team at 116 for six in the 28th over.
Having smoked lead pacer Rabada's length ball outside off for a six over long-on, Rahmanullah Gurbaz (25) found the fence again when he produced a lovely cover driver against the same bowler.
Desperately looking for a breakthrough, Bavuma introduced Keshav Maharaj into the attack and the left-arm spinner straightaway responded with the big wicket of Gurbaz, who edged a turning delivery to Klaasen at first slip.
Not only did Maharaj strike with his first ball he also enjoyed a wicket-maiden, giving South Africa a bit of a momentum which they used to their advantage by quickly grabbing two more wickets.
Much was expected of Ibrahim Zadran, who scored a brilliant hundred against Australia in their last game, but the opener was done in by a short ball from Coetzee.
Omarzai, however, continued to fight it out.