New Zealand went top of the World Cup table as a thrilling four-wicket win at Edgbaston effectively ended South Africa's interest in the tournament.
Chasing a modest 241 for victory in a 49-over contest, New Zealand were in trouble at 80 for four after opener Martin Guptill had been dismissed in freak fashion.
But Kane Williamson played a true captain's innings, making an unbeaten 106 from 138 balls, and crucial support from Colin De Grandhomme saw the Black Caps home with three balls to spare as they retained their unbeaten record.
It was a classy performance from Williamson, refusing to panic when wickets were lost around him, while De Grandhomme bludgeoned boundaries at the right time.
But how South Africa will curse lost opportunities. David Miller, having just been inches from catching Williamson off Imran Tahir, was unable to hold on to a difficult one-handed chance from the spinner when De Grandhomme was on 22.
Williamson should also have been run out on 77, but he went on to complete a 12th ODI hundred – levelling the scores with a six before striking the winning four off Andile Phehlukwayo.
South Africa skipper Faf Du Plessis had declared his side could afford no more slip-ups after taking only three points from their opening five games.
So South Africa's dream of a first World Cup win looks over, even if progress to the last four still remains mathematically possible.
New Zealand's chase was being conducted with a minimum of fuss despite the early loss of Colin Munro, who had offered a return catch to Kagiso Rabada after being surprised by extra bounce.
But then Guptill went in bizarre fashion, losing his balance as he pulled Phehlukwayo through mid-wicket and treading on his stumps.
Guptill became the first New Zealander to be out hit-wicket in World Cup history, and the 10th from all countries.
Chris Morris then had Ross Taylor and Tom Latham caught behind and New Zealand had lost four wickets for eight runs in the space of 20 balls.
New Zealand were still 105 runs short of victory when Jimmy Neesham became the fifth man out, but De Grandhomme played superbly before holing out in the penultimate over.
South Africa made 241 for six with Rassie Van Der Dussen (67 not out) and Hashim Amla (55) both making half-centuries, yet never dominating the Black Caps' attack.
Lockie Ferguson took three for 59 with his extra pace, but Matt Henry, De Grandhomme and Mitchell Santner all delivered useful economy rates.
Heavy overnight rain had delayed the start of play by 90 minutes with two overs lost as a result.
After New Zealand had won the toss and sought to exploit overcast conditions, Trent Boult swiftly knocked over Quinton De Kock's leg stump before Amla found some fluency after a disappointing World Cup.
Amla had further satisfaction by becoming the fourth South African to reach 8,000 runs in ODI cricket after Jacques Kallis, AB De Villiers and Herschelle Gibbs.
Du Plessis had made 23 when he was beaten by Ferguson's searing yorker, the prelude to an even more patient partnership between Amla and Aiden Markram.
Amla showed touches of his old self by dispatching Boult for successive boundaries but, having reached 50 from 75 balls, he was undone when Santner turned one past his outside edge to clip the top of off-stump.
Curiously, it was only the fifth time in World Cup history that the top three batsmen had all been bowled.
Markram made 38 from 55 balls, but it was not until Van Der Dussen and David Miller came together that South Africa managed some belated aggression.
Miller passed 3,000 ODI runs during his 37-ball 36 and Van Der Dussen struck three sixes in his 64-ball stay, but the stage was left to Williamson to play the decisive innings of the match.