Guptill, who missed the first match through illness, finished unbeaten on 101 off 69 balls with nine fours and half-a-dozen sixes as the Blacks Caps successfully reached their target of 169 in a match reduced to 19 overs a side due to a floodlight failure.
Guptill rode his luck, though, and was caught off a no-ball late on before then being dropped by Robin Peterson at point off a skier when on 89 with New Zealand needing 19 runs off 10 balls in East London.
The opener made the most of those escapes to become the second New Zealand batsman to score a Twenty20 international century after Brendon McCullum as he scooped the final delivery of the match from Rory Kleinveldt over the infield and away for the match-winning four.
South Africa had made 165 for five with captain Faf du Plessis top-scoring with 63, opener Henry Davids contributing 55 and David Miller clubbing a quickfire 33.
A floodlight failure during the 17th over of South Africa's innings saw a significant delay that led to the match being reduced to 19 overs.
The victory sees New Zealand level up the three-match series at 1-1 with the deciding match taking place in Port Elizabeth on Wednesday. South Africa won the first match by eight wickets after bowling New Zealand out for 86.
- Sports & Recreation
- New Zealand