Hamilton - Kane Williamson had New Zealand on the brink of victory after a spectacular Sri Lanka collapse on the third day of the second Test in Hamilton on Sunday.
New Zealand were 142-5 at the close of play, requiring a further 47 runs to claim the Test and sweep the series.
Shortly before lunch on the third day their hopes of a win seemed remote with Sri Lanka 126 runs ahead and with all second innings wickets in hand.
But the tourists' fortunes swung from commanding to catastrophic when the 10 wickets fell for 62.
New Zealand went from being 55 behind on the first innings to chasing a target of 189 to win.
Williamson was not out on 78 at stumps, in sight of his 13th Test century with BJ Watling yet to score.
If there was a bright spot for Sri Lanka it was the emergence of Dushmantha Chameera as a genuine wicket taker, taking four for 45 in New Zealand's second innings to give him nine wickets so far for the match.
Openers Tom Latham and Martin Guptill fell cheaply as Chameera had New Zealand at 11-2 before Williamson and Ross Taylor (35) revived the innings with 67 for the third wicket.
Brendon McCullum (18) followed Taylor to the crease for a fourth wicket stand of 52.
On a firm pitch offering good bounce, 16 wickets fell on the day after Trent Boult was the last New Zealand first innings dismissal on the sixth ball of the morning.
An inability to control short, accurate deliveries on a firm wicket was a common theme which featured catches with six of the Sri Lankan dismissals and all six New Zealand wickets.
Taylor was caught in a clever piece of fielding at long leg by Jeffrey Vandersay.
When the substitute fielder took the ball he threw it high as his momentum took him over the rope and he then returned to the field to complete the catch.
Sri Lanka had made a good start to building on their first innings advantage with Kusal Mendis and Dimuth Karunaratne putting on 71 in the best opening partnership for Sri Lanka in 12 months.
But when Doug Bracewell claimed Karunaratne for 27 it ignited the Sri Lanka collapse.
Bracewell had Udara Jayasundera two balls later and Neil Wagner dismissed Dinesh Chandimal for one as Sri Lanka tumbled to 77 for three.
Mendis and Angelo Mathews held the innings together to reach 85-3 at lunch before it completely unravelled after the interval.
Mendis had equalled his Test best 46 when he top-edged Tim Southee and was caught on the boundary by Mitchell Santner.
It was the start of a remarkable burst for Southee in which he removed Mathews, Rangana Herath and Nuwan Pradeep to take four for 10 in a 4.3-over burst.
In a day built around the short-ball strategy, Herath was the only player to be bowled.
Milinda Siriwardana tried to belt the side out of trouble racing to 26 before slogging at a rare fullish delivery from Wagner and was caught by Boult at deep mid-wicket.
Southee finished with four for 26.
A win for New Zealand will extend their unbeaten run in home Tests to 13, equalling the record set from 1987-91.