A world record sixth-wicket partnership of 365 by Kane Williamson and BJ Watling, who both posted career bests, slammed the door on Sri Lanka in the second Test in Wellington Tuesday.
Williamson's unbeaten 242, with Watling not out 142 rescued New Zealand from a deep hole and carried them to 524-5 declared in their second innings.
Sri Lanka were left facing a 390-run target on a ground where the record for a successful fourth innings chase is 277-3 set by Pakistan 11 years ago.
At stumps they were 45-1 with Kaushal Silva on 20 and Dhammika Prasad on one.
Dimuth Karunaratne was out for 17 four overs before the close to be the only dismissal of the day.
With wickets hard to come by on a flat track, and with Sri Lanka holding middle-order strength led by Kumar Sangakkara, a draw seemed the likely outcome which would give New Zealand the two Test series 1-0.
Brought together as New Zealand's last recognised batsmen with the score at 159-5, a perilous 24-run lead, Williamson and Watling methodically ground the Sri Lankan bowlers into submission over the following eight hours.
The declaration came when they were 13-runs ahead of the previous sixth-wicket record of 352 set by Watling with Brendon McCullum in similar Test-saving circumstances against India a year ago.
Then, as now, New Zealand were fighting to claim the series after winning the first Test.
Sri Lanka were not without chances to break the partnership and regain control and they paid a heavy price for sloppy fielding.
Williamson offered four chances -- dropped by Rangana Herath on 29, dropped by Nuwan Pradeep on 60, dropped by Prasanna Jayawardene on 104 before Jayawardene missed a blatant stumping opportunity on 233.
Williamson's unbeaten 242, the product of more than 10 hours at the crease, gave the 24-year-old his ninth Test century and the seventh highest score by a New Zealander.
After cautiously steering New Zealand into a commanding position, Williamson opened up towards the end of the innings scoring 52 of the 79 runs added in the 15 overs before the declaration.
In his marathon innings he faced 438 deliveries and scored 18 fours including a boundary to midwicket when he confidently danced down the wicket to bring up his maiden 200 by clipping Rangana Herath to the ropes.
While Williamson steered New Zealand to safe waters, Watling proved a sound ally at the other end as he brought up his fourth Test century and had nine fours and a six in his 142.
His previous best was 124 in his match-saving knock with McCullum against India.
As the innings progressed the Sri Lankan captain Angelo Mathews set defensive fields hoping the batsmen would make a mistake, but when the chances came they were not taken.
Herath, the leading bowler in the world last year with 60 wickets at 24.85, finished with figures of one for 154.
Sri Lanka's most successful bowler Pradeep had figures of three for 117 after being three for 32 before Watling went to the middle.