New Zealand went into the last over at 234-6 and chasing 242 for victory. Andile Phehlukwayo's first ball was sent for a single by Mitchell Santner, sensibly giving Williamson the strike, and the New Zealand captain immediately took his chance with a powerful six.
Williamson finished 106 not out off 138 balls as New Zealand reached 245-6 in a match reduced to 49 overs each innings. He called it "a great game of cricket on a surface that was tough for both sides."
The win moved New Zealand atop the standings and effectively put an end to South Africa's chances of reaching the playoffs. "I'm feeling five years older. My body is really sore after that," South Africa captain Faf du Plessis said. "We left everything out there, and that's all I can ask for as a captain, that the guys fought."
So did Williamson, who was brilliantly supported and occasionally overshadowed by Colin de Grandhomme, who smashed a 47-ball 60, with five fours and two sixes. De Grandhomme impatiently holed out to du Plessis at long-off to a delivery from Lungi Ngidi at the start of the penultimate over — the 48th — while going for his third six.
Despite the late stress caused by that dismissal, Williamson was keen to praise his teammate. "The partnership and the knock from Colin was outstanding in terms of swinging that momentum, and he hit the ball beautifully," Williamson said.
Williamson and de Grandhomme joined with the total at 137-5 in reply to South Africa's 241-6 off 49 overs, and their partnership was crucial in guiding New Zealand to its fourth win of the tournament.
The Black Caps now have nine points, one clear of top-ranked England and defending champion Australia. At the other end of the table, South Africa is almost certainly out of contention — in the first major shock of the 2019 edition — with only three points from six games.
The New Zealanders appeared content with the run chase ahead of them but the wicket was trickier than it appeared, and the chase far harder. Except for Williamson. The Black Caps had kept an unchanged XI from its last completed match against Afghanistan on June 8. Fast bowler Ngidi (1-47) returned from a hamstring injury in South Africa's only change from its nine-wicket win over Afghanistan last Saturday.
Williamson won everything on Wednesday, including the toss. And while New Zealand failed to bowl out a team for the first time at the tournament, South Africa's total appeared too little to test the Black Caps. Yet the result was in the balance until the end.
"Obviously, I'm extremely disappointed. Cricket means a lot to me, and the performance of this team means a lot to me," du Plessis said. Hashim Amla reached a personal landmark as the second-quickest batsman with 8,000 runs in ODIs, but the 36-year-old opener again took his time with an 83-ball 55 before falling to Santner's spin.
Amla shared a 50-run second-wicket partnership with du Plessis (23) and a 52-run third-wicket stand with Aiden Markram (38). But it was mostly slow going. Rassie van der Dussen provided some late-innings impetus with an unbeaten 67 off 64 balls, with two fours and three sixes. David Miller scored a lively 36 from 37. The pair shared a partnership of 72.
Miller swung and hit intimidating quick Lockie Ferguson for a four to bring up the 200 at the start of the 45th over and clipped the pacer away for another boundary right after. Ferguson had the last laugh in the same over when Miller top edged deep to Trent Boult at third man.
Boult had bowled Quinton de Kock for 5 to win an early battle but finished on 1-63. Ferguson did the most damage with 3-59 while Matt Henry bowled tightly, with two maidens, ending on 0-34. Martin Guptill became the first New Zealander to be dismissed by hitting his own wicket in any Cricket World Cup tournament, dating back as far as 1975. In the end it didn't matter.
"There's a huge amount to learn from this performance," Williamson said, "The experiences that you have by being put under pressure on a number of different occasions, whether it's with the bat or the ball, having close games in tournaments like the World Cup are great to be a part of, especially when you come out on the right side of things."
More AP cricket: www.apnews.com/cricket and https://twitter.com/AP_Sports