A Daryl Mitchell century and a brilliant 72 from Matt Henry helped New Zealand to an unlikely first-innings lead of 18 runs before the home bowlers restricted Sri Lanka to 83/3 at the end of the third day of the first Test on Saturday.
Sri Lanka will take a 65-run lead into Day 4 in Christchurch but that will be scant consolation for blowing a dominant position in a match they need to win to keep alive their hopes of reaching the World Test Championship (WTC) final.
The Black Caps resumed on 162/5, still trailing Sri Lanka's 355 by almost 200 runs, but Mitchell quickly made it clear he was determined to cut the deficit to a manageable tally as he worked his way to his fifth Test century.
After all-rounder Michael Bracewell had departed for 25, Mitchell put on 47 with skipper Tim Southee (25) and another 56 with Henry before being caught behind off Lahiru Kumara for 102 with parity 64 runs away.
Supported by an equally aggressive 27 from Neil Wagner, Henry took the game to the Sri Lankan bowlers and plundered 24 runs off one Kasun Rajith over to edge the Black Caps into the lead.
His 75-ball innings came to an end when he was bowled by a Asitha Fernando yorker, the wicket giving the Sri Lanka seamer figures of 4/85.
A final flourish from Wagner eked out the lead a little further before the New Zealand bowlers put away their bats and got down to the business of trying to drive home the advantage.
The bowling was tight rather than spectacular and Blair Tickner, the one bowler who never really got started with the bat, took all three wickets at the expense of 28 runs.
Skipper Dimuth Karunaratne departed for 17 to a fine catch by Henry Nicholls at gully, while Oshada Fernando made 28 from 52 balls before he edged the ball behind.
Kusal Mendis was caught in the slips off an imprudent shot leaving Angelo Matthews (20 not out) and Prabath Jayasuriya (2 not out) to resume on Sunday.
Sri Lanka will qualify for the WTC final if they can sweep New Zealand in this two-Test series and if Australia can deny India victory in the fourth Test in Ahmedabad.
'Green will be the world's best all-rounder'
IPL 2023: Seen Mumbai Indians Jersey?
PIX: What The Fans Want From Kohli
'Class' Ashwin overtakes Kumble
SEE: Dhoni's H-U-G-E Sixes!