New Zealand conjured up a remarkable victory for the second time in two weeks by chasing down a target of 285 runs on the final ball of the rain-shortened final day to beat Sri Lanka by two wickets in the first test in Christchurch on Monday.
The dramatic win, which came on the back of the one-run victory over England after following on in Wellington, put the hosts 1-0 up in the two-match series and ended Sri Lanka's hopes of playing in the World Test Championship (WTC) final.
Kane Williamson played the leading role by notching up his 27th test century in a beautifully controlled innings of 121 not out after the first four-and-a-half hours of play at Hagley Oval had been washed out by rain.
The winning run came when the former captain and the injured Neil Wagner ran a bye, Williamson securing the victory by diving full length to get his bat down in the crease before a direct hit broke the stumps.
The Black Caps went into the final day on 28-1 needing 257 more runs for victory and after the rain finally cleared were allowed 52 overs in one extended session to achieve the task.
First-innings centurion Daryl Mitchell contributed 81 to a stand of 142 with Williamson for the fourth wicket that put victory within grasp but there were plenty of nervous moments before the win was finally secured with eight wickets down.
"As along as we had someone like Kane at the crease, the guys were very trusting in what he was going to do," said New Zealand captain Tim Southee.
"He's just a world class player and I think world class players are able to perform in different conditions and different situations. Seeing him so calm in the middle kept us all calm on the sidelines."
Sri Lanka were still chasing a win that would keep them on course for a spot in the WTC final and Prabath Jayasuriya put them on the front foot with two early wickets.
The left-arm spinner bowled Tom Latham for 25 and had Henry Nicholls caught in the deep for 20 but that only brought Williamson and Mitchell together in the middle.
Seamer Asitha Fernando (3-63) gave Sri Lanka renewed hope with yorkers to dismiss Mitchell and Tom Blundell (3) before having Michael Bracewell (10) caught at deep midwicket.
Dramatic finish
That set up the dramatic finish with New Zealand needing 15 runs from the last two overs, and local nerves intensified when Southee holed out in the deep and Matt Henry was run out.
Williamson kept his own nerve and clubbed a four off the fourth ball of the final over but Fernando's last two deliveries were short and high, giving the batsmen no option but to go for an undignified scramble to secure victory.
The tourists would have qualified for the WTC final if they had swept New Zealand 2-0 and Australia denied India victory in the ongoing fourth test in Ahmedabad.
Sri Lanka made a promising start to their quest by making 355 in their first knock and looked set to take a commanding first-innings lead when their bowlers reduced New Zealand to 162-5 at the end of day two.
Mitchell marshalled the New Zealand rearguard with his fifth test century, however, and the hosts grabbed back the momentum to take a lead of 18 after posting 373.
A 14th test century from Angelo Matthews dragged Sri Lanka right back into the contest with a second innings tally of 302 on Sunday.
"Unfortunately we were on the losing side but I think overall we did a really great job," said Sri Lanka captain Dimuth Karunaratne.
"In previous tours we haven't been able to do much here but we were ahead of the game on days two and four. As a captain, I'm really happy with the boys."
India will now take on Australia, who had already qualified, in the WTC final at The Oval in London starting on June 7.