Guptill, who had suffered two separate hamstring strains and not played for a month, scored 180 not out and combined with Ross Taylor (66) in a 180-run partnership to take New Zealand to 280-3 in 45 overs.
The 30-year-old blasted 11 sixes and 15 boundaries in his swashbuckling 138-ball knock to secure a win which locked the five-match series at 2-2 with the decider at Eden Park in Auckland on Saturday.
South Africa's 279-8 had been anchored by captain AB de Villiers, who flayed New Zealand bowlers all around Seddon Park in the final few 'death' overs to finish on 72 not out.
The total had looked to be a difficult one to achieve on the slow-paced pitch but Guptill seized control of the chase with arguably the best innings of his career.
He brought up his half century off 38 balls and then had an lbw decision to Dwaine Pretorius on 62 overturned on review before he reached his 12th ODI century from 82 balls, which included 12 boundaries and four sixes.
Taylor also survived after he was given out on 40 to a catch by Quentin de Kock, before third umpire Joel Wilson overturned it while reviewing replays that showed the ball had bounced just in front of the wicketkeeper.
South Africa again paced the start and end of their innings almost to perfection with Hashim Amla (40) and Faf du Plessis (67) giving them a solid foundation.
The middle order then failed to capitalise as they lost four wickets for 28 runs in 10 overs as New Zealand dragged themselves back into the match.
De Villiers, however, again combined with the bowlers to finish off the innings as they scored 104 runs in the final 10 overs, with 72 coming in the final five.
The 32-year-old combined with Chris Morris (28) for 58 runs before he added 63 runs with Wayne Parnell, who bludgeoned 29 runs from 12 balls.
AB de Villierscrickethamiltonhamilton ODIMartin Guptillnew zealand vs south africaNew Zealand vs South Africa 2017
First Published: March 1, 2017, 2:36 PM IST