Kane Williamson hit a sublime unbeaten century to lead New Zealand to a thrilling two-wicket win over Sri Lanka off the final ball of the first Test.
Williamson’s 121 not out saw the Black Caps chase down 285 on a rain-shortened fifth day in Christchurch.
The hosts needed eight off the final over and scrambled a bye from the last ball to seal a dramatic win.
Defeat ended Sri Lanka’s hopes of reaching the World Test Championship final in June.
Sri Lanka needed to sweep New Zealand 2-0 in this series to qualify, so India will now face Australia in the final at The Oval.
The fourth and final Test between the two sides in Ahmedabad finished in a draw, ensuring India won the series 2-1.
The Black Caps started the final day on 28-1, requiring 257 more runs for victory.
After the first two sessions were washed out, the umpires ruled there would be a maximum of 52 overs bowled in an extended final session, meaning New Zealand had to score at nearly five runs per over.
They slipped to 90-3 before Williamson combined with Daryl Mitchell for a 142-run stand off 157 balls, with Sri Lanka left to rue wicketkeeper Niroshan Dickwella dropping Williamson on 33.
New Zealand wobbled after Mitchell was bowled for 81 by Asitha Fernando, who then also removed Tom Blundell and Michael Bracewell. It left the hosts on 266-6, needing a further 19 runs with 16 balls remaining.
Captain Tim Southee also fell, but Williamson managed to take the match to the final over.
Matt Henry was run out attempting a second run off the third ball, bringing an injured Neil Wagner to the crease. The fast bowler has a bulging disc in his back and a torn right hamstring and has been ruled out of the second Test.
Williamson sliced the next delivery through point for four to level the scores before Fernando bowled a bouncer that was close to being called wide on height but was ruled a dot ball.
With one needed from the last ball, New Zealand ran a bye through to the keeper after Williamson’s missed pull shot and he just managed to slide his bat down in time despite a direct hit at the non-striker’s end.
It is New Zealand’s second thrilling Test win in a row, following their stunning one-run victory over England last month.
“Seeing how calm Kane is out in the middle keeps us calm as well,” said Southee.
“He’s a world-class player and world-class players are able to perform in different conditions.
“The guys were very trusting in what he was going to do and, alongside Daryl, for most of the day it was a great partnership that got us in that great position.”
The second Test at the Basin Reserve in Wellington starts on Friday.