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.
"It was just one of those innings that went to plan," Guptill said. "It's about keeping it as simple as possible and watch the ball and react, it does make it a bit easier.
"I had a couple of good nets the last few days but it was nice to go out there and hit it out of the screws."
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 a leg before 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.
"Guppy was unbelievable. Probably the best knock I've ever seen," New Zealand captain Kane Williamson said.
"At the halfway stage we certainly would have liked to have restricted them to a total a lot less than what they got.
"For Martin to come out and play a hand like that it was a special knock."
De Villiers then 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.
"I was pretty confident with the 280 target we set," de Villiers said.
"I thought we had a good chance but we... needed to get Martin out. He is one of those players who can take the game away from you."