A record partnership by Martin Guptill and Kane Williamson gave New Zealand victory with two balls to spare in a tense third one-dayer against Pakistan in Auckland on Sunday.
The three-wicket win in the rain-abridged match also wrapped up the series for New Zealand 2-0.
Initially set a target of 291 to win, New Zealand made a disastrous start with Brendon McCullum out for a first-ball duck.
But Guptill and Williamson restored order with a 159-run stand, a New Zealand ODI record for the second wicket, to set the side up before a lengthy rain delay shortened the match by seven overs.
When play resumed, New Zealand were set a revised target of 53 off 45 balls, which they reached with two balls to spare and with the help of a contentious umpire's call.
With 27 balls remaining and New Zealand still 38 runs short of their target, Corey Anderson appeared to have been caught behind but was given not out and Pakistan had used up their review.
The ODI series win added to New Zealand's golden summer after they also beat Pakistan 2-1 in the Twenty20s and beat Sri Lanka in Tests, ODIs and Twenty20s.
In the decider against Pakistan, Azhar Ali won the toss and opted to bat first which initially proved productive.
While Babar Azam and Mohammad Hafeez were together it looked like they would threaten the Eden Park ODI innings record of 340.
Even with Hafeez back in the pavilion, Pakistan were 207-3 with 20 overs remaining.
But they were soon to run out of steam with their last six wickets falling for 63 runs and they were all out for 290 with 15 balls remaining.
McCullum's comeback was very brief after being sidelined for five weeks by a back complaint.
The first ball he faced from Mohammad Amir was hooked to long leg where Mohammad Irfan took a smart catch on the run.
Enter Williamson to partner Guptill in a record stand, two better than the previous best 157 which Guptill had set with McCullum four years ago against Zimbabwe.
Azhar removed the pair in the space of eight deliveries.
Guptill was first to go for 82 caught at point by Hafeez, and Williamson was stumped for 84.
Azhar may consider himself a part-time bowler but showed all the guile of a career leg-spinner when he outwitted Williamson charging down the wicket by getting the ball through to wicketkeeper Sarfraz Ahmed.
Henry Nicholls, who set up the first ODI win, and Grant Elliott both fell cheaply as New Zealand slipped from 165-1 to 210-5.
Lusty hitting from Anderson with 35 off 29 narrowed the gap and with six required off the last over, Mitchell Santner hit boundaries off the first and fourth deliveries to get New Zealand home.
Santner hammers another boundary for the winning hit as New Zealand win by three wickets (D/L method) and two balls to spae to win the series 2-0.
Santner slams a length ball from Riaz through the off for a boundary.
New Zealand need six off the last over with three wickets in hand.
Azam takes a skier as Anderson departs. NZ 256-7, 41.3 overs.
Corey Anderson c Babar Azam b Mohammad Irfan 35 (29b 1x4 3x6)
New Zealand 10 off 12 balls with four wickets in hand.
Riaz strikes to knock the middle stump of Ronchi. NZ 253-6, 41 overs.
Luke Ronchi b Wahab Riaz 20 (21b 1x4 1x6)
New Zealand need 13 off 18 balls.
Ronchi joins the party by clobbering Amir for a massive straight six. NZ 250-5, 40 overs.
Anderson is leading the charge slamming Amir through the off for a boundary.
Anderson survives after being adjudged not out despite replays suggesting he had got a faint nick behind off Rahat before belting a couple of sixes to close the gap. NZ 237-5, 39 overs.
Ronchi survives as Hafeez fails to latch onto a chance off a miscued shot. NZ 222-5, 38 overs.
Ronchi gets into his stride by cracking Irfan to backward point for a boundary.
The match has been reduced to a 43 over game.
New Zealand need another 53 runs to win off 45 balls with the D/L target being 263.
The rain has got heavier and it has to stop completely for play to resume again.
New Zealand are six runs ahead of the par score at the fall of the fifth wicket which is 204. NZ 210-5, 35.3 overs.
The covers have finally come on because of a steady drizzle.
Pakistan get a lucky break as Elliott slaps Malik straight to point. NZ 210-5, 35.3 overs.
Grant Elliott c Babar Azam b Shoaib Malik 10 (17b)
Anderson skips out and hammers Azhar over midwicket for a massive six. NZ 208-4, 35 overs.
Amir has struck trapping Nicholls who shuffles across and Pakistan are back in the hunt. NZ 188-4, 31.1 overs.
Henry Nicholls lbw b Mohammad Amir 5 (13b)
Pakistan are attacking with Amir with two new batsmen in the middle. NZ 184-2, 30 overs.
Azhar has struck again bamboozling Williamson with a turner as the batsman gave the charge. NZ 180-3, 28.3 overs.
Kane Williamson st Sarfraz Ahmed b Azhar Ali 84 (86b 9x4 3x6)
Williamson is turning it on slamming a boundary and six off Irfan. NZ 179-2, 28 overs.
Azhar breaks the record partnership as Guptill slices to point. NZ 165-2, 26.2 overs.
Martin Guptill c Mohammad Hafeez b Azhar Ali 82 (81b 8x4 3x6)
Willamson heaves Riaz for sweetly timed straight six. NZ 163-1, 26 overs.
The 150 partnership between Guptill and Williamson which is a New Zealand record against Pakistan comes off just 142 balls. NZ 156-1, 25 overs.
Williamson reaches out to a wide ball to get a boundary off Azhar with the toe end of the bat as New Zealand cruise.
Azhar Ali comes into the attack and Guptill greets him by slapping a long hop down the ground for a boundary. NZ 144-1, 23 overs.
Williamson slams Riaz powerfully down the ground past the bowler and swings him around for another boundary to bring up his half century. NZ 136-1, 22 overs.
Guptill has swept Malik for another boundary.
Guptill almost drags Malik from off to sweep him for a boundary. NZ 113-1, 19 overs.
The 100-run partnership between Guptill and Williamson comes off 102 balls.
Spin for the first time as Malik comes into the attack.
There is rain and sun is out despite a drizzle which threatens to curtail play which goes on for now. NZ 105-1, 18 overs.
Wahab leaks a couple of boundaries to fine leg. NZ 101-1, 17 overs.
Guptill has slammed Rahat over extra cover for a boundary followed by a straight drive to the fence to complete his half century. NZ 90-1, 16 overs.
Williamson tees off by swinging Irfan for a towering six over midwicket to break the shackles. NZ 75-1, 14 overs.
Riaz bowls an excellent opening over conceding just two runs as New Zealand's asking rate mounts to over six an over. NZ 64-1, 13 overs.
Guptill gets a streaky boundary to fine leg off an inside edge off Rahat. NZ 58-1, 11 overs.
Amir has bowled brilliantly in the Batting Powerplay returning figures of 5-0-15-1. NZ 52-1, 10 overs.
Williamson drives Rahat down the ground for a delightful boundary. NZ 51-1, 9 overs.
Rahat comes into the attack and Guptill welcomes him by slamming him straight into the sightscreen. NZ 44-1, 7 overs.
Guptill hooks a bouncer from Amir over fine leg for another six while Williamson survives after squaring shoulders and being rapped on the pads with Pakistan losing the decision review. NZ 38-1, 6 overs.
Williamson gets going cracking Irfan through point and pulling another to midwicket for a couple of boundaries. NZ 29-1, 5 overs.
Guptill gives himself room and has slammed Irfan over long-off for the first maximum. NZ 15-1, 3 overs.
Amir has drawn first blood as McCullum is dismissed for a golden duck top edging to long leg where Irfan takes a superb catch. NZ 6-1, 1.1 overs.
Brendon McCullum c Mohammad Irfan b Mohammad Amir 0 (1b)
Guptill punches Irfan past point for a boundary as New Zealand begin chasing 291. NZ 6-0, 1 over.
Pakistan collapsed from 200 for 3 to be all out for 290 in 47.3 overs.
Scoreboard in the third and final One Day International between New Zealand and Pakistan on Sunday in Auckland, New Zealand
Az. Ali c Guptill b Henry 3
A. Shehzad c Guptill b Boult 12
M. Hafeez c Milne b Santner 76
B. Azam c Guptill b Henry 83
S. Malik c Ronchi b Boult 32
S. Ahmed c Ronchi b Milne 41
M. Rizwan run out (Elliott) 16
W. Riaz c Guptill b Anderson 11
M. Amir c Ronchi b Milne 1
R. Ali c Ronchi b Milne 0
M. Irfan not out 0
Extras (nb-1 w-14) 15
Total (all out, 47.3 overs) 290
Fall of wickets: 1-16 A. Shehzad,2-20 Az. Ali,3-154 M. Hafeez,4-215 S. Malik,5-227 B. Azam,6-256 M. Rizwan,7-279 W. Riaz,8-284 M. Amir,9-284 R. Ali,10-290 S. Ahmed
T. Boult 9 - 0 - 60 - 2(nb-1 w-3)
M. Henry 10 - 0 - 44 - 2(w-3)
C. Anderson 4 - 0 - 26 - 1(w-1)
M. Santner 5 - 0 - 56 - 1(w-1)
A. Milne 9.3 - 0 - 49 - 3(w-2)
G. Elliott 10 - 0 - 55 - 0
Umpire: Billy Bowden
Umpire: Nigel Llong
TV umpire: Bruce Oxenford
Match referee: David Boon
Pakistan won toss and decided to bat
New Zealand: Martin Guptill, Brendon McCullum (capt), Kane Williamson, Henry Nicholls, Grant Elliott, Corey Anderson, Luke Ronchi, Mitchell Santner, Adam Milne, Matt Henry, Trent Boult
Pakistan: Azhar Ali (capt), Ahmed Shehzad, Mohammad Hafeez, Babar Azam, Shoaib Malik, Mohammad Rizwan, Sarfraz Ahmed, Wahab Riaz, Mohammad Amir, Mohammad Irfan, Rahat Ali
Referees: David Boon (Match referee), Bruce Oxenford (TV umpire), Nigel Llong (Umpire), Billy Bowden (Umpire)
Brendon McCullum said he expects to return to the New Zealand team for the deciding one-day international against Pakistan in Auckland on Sunday, however explosive opener Martin Guptill is now doubtful.
Guptill twisted an ankle in training on Saturday and was rated by coach Mike Hesson as "a 50:50 prospect" of playing in the third and final match of the series.
Captain McCullum, whose farewell tour has been disrupted since a back injury flared up five weeks ago, said he expected to play in the last match against Pakistan and then the Australia series in February before retiring.
"I've had a good couple of hits," he said of his work in the nets over recent days.
"It's probably not 100 per cent but there's a bit of stiffness so hopefully I'll be fine for tomorrow."
New Zealand, who beat Pakistan 2-1 in the Twenty20s, comprehensively won the first ODI by 70 runs with the second match washed out.
While they need to win in Auckland to claim the series, Hesson said he would not risk Guptill if he is not fully fit.
"We won't play him unless he's fit," he said.
"Twisted ankle is one of those ones he could wake up and be fine or it could be sore for 24-48 hours."
Tom Latham, who has opened for New Zealand in McCullum's absence, will play if either McCullum or Guptill pulls out of the Pakistan match.
He was also picked as standby cover in the ODI squad named Saturday for the Australia series in case McCullum breaks down again.
New Zealand have been hard hit by injuries with Ross Taylor, Tim Southee and Mitchell McClenaghan all unavailable to play Australia and Hesson said that will test the depth of his squad.
"This is a pinnacle event for us and we'll look to get our best side out on the park each time we play," he said.
"We've been lucky enough to use a big squad over the summer and although we're missing a few key players, we have guys who can step in and we know are up to the task."
New Zealand ODI squad to play Australia: Brendon McCullum (capt), Corey Anderson, Trent Boult, Doug Bracewell, Grant Elliott, Martin Guptill, Matt Henry, Adam Milne, Colin Munro, Henry Nicholls, Luke Ronchi, Mitchell Santner, Kane Williamson.