
De Villiers scored 37 not out and ensured number eight batsman Andile Phehlukwayo (29) kept a cool head as the pair put on 54 to reach their 208-run victory target and earn a 1-0 lead in the five-match series.
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.
AB de Villiers of South Africa (L) and his teammate Andile Phehlukwayo celebrate winning the ODI against New Zealand at Seddon Park in Hamilton AFP 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.
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.BRIEF SCORES:34 overs a side:South Africa 210 for 6 (de Kock 69, de Villiers 37*, Santner 1-33, Sodhi 1-36) beat New Zealand 207 for 7 (Williamson 59, Morris 4 for 62) by four wickets
