The visitors, who had looked to be cruising to victory at 117-1 with 14 overs remaining courtesy of Quinton de Kock’s 69, lost four wickets in 14 balls to slump to 126-5 before Chris Morris helped his captain in a 30-run partnership.
South Africa needed 22 runs from the final two overs and scored 10 from Trent Boult in the penultimate one which included a six from Phehlukwayo, who repeated the feat against Tim Southee in the final over.
De Villiers belted Southee for four off the penultimate ball to clinch the victory.
New Zealand made 207-7 after heavy rain over the past three days had forced a delay of more than three hours and reduced the match to 34-overs-a-side.
“It was really tough out there,” De Villiers said. “The wicket turned so much in the evening. I thought it would skid on and get a bit flatter.
“From past experience this becomes a good batting track in the evening and this was far from it.
“I’ve never seen a wicket turn so much in my life.”
New Zealand struggled for much of their innings particularly up front against tight bowling from Morris, who took the first four wickets as the hosts slumped to 82-4 in the 16th over.
But Morris, who had figures of 4-24 from his first five overs, was then taken apart by Colin de Grandhomme (34 not out) and Southee (24 not out) in his final two.
De Grandhomme and Southee blasted 51 runs from 23 balls, including smashing 38 runs from Morris’s final 12 deliveries to blow out his figures to 4-62 from seven overs.
“Bit of a shame really. We got ourselves into a good position but credit to South Africa, they adapted really well,” said New Zealand captain Kane Williamson, who top-scored for his side with 59.
“We weren’t perfect with the bat but we felt that 5-1/2 a half an over would be tough to get on that surface and we had enough to make life difficult.”
The second match is in Christchurch on Wednesday.
(Reporting by Greg Stutchbury in Napier; Editing by Amlan Chakraborty and Ed Osmond)