But Guptill, on 35, was dismissed hit-wicket trying to pull Andile Phehlukwayo to the boundary and Chris Morris bowled a fiery spell to get rid of Ross Taylor and Tom Latham, both caught behind for one run.

Morris also had Jimmy Neesham caught at slip for 23 to leave New Zealand struggling at 137-5, but Williamson and Colin de Grandhomme (60) shared a composed 91-run partnership to ease New Zealand nerves.

Advertisement

The result left South Africa, who have won only one match, virtually out of the running for a semi-final spot while New Zealand kept their unbeaten run intact to move to the top of the standings with four wins in five games.

South Africa had a golden opportunity to run Williamson out after a mix-up with De Grandhomme left the Kiwi skipper well short of his ground but David Miller fluffed the chance, whipping the bails off without collecting the ball.

New Zealand skipper Kane Williamson's ton proved pivotal.Credit:AP

De Grandhomme fell before the end but Williamson reached his century with a six in the final over and guided New Zealand to their fourth win of the tournament with three balls to spare.

"It was nice to be there at the end," said Williamson who finished unbeaten on 106.

Loading

"It's just trying to do the job as well as you can, I was fortunate I was able to do it today. There were a number of contributions that were so vital.

"It was one of those surfaces that provides a great spectacle. It could have gone either way."

South Africa's batsmen apart from Hashim Amla and Rassie van der Dussen failed to build on starts after being put into bat in the face of a disciplined bowling effort from the Kiwis.

Amla was bowled for 55 by Mitchell Santner but Van der Dussen's unbeaten 67 off 64 balls gave the South Africans a respectable total to defend.