BJ Watling rescued New Zealand with a gutsy unbeaten 63 as the visitors overcame a batting collapse to reach 195-7 in their second innings on Day 3 of the opening Test against Sri Lanka on Friday.
The tourists, having conceded an 18-run first innings lead, were reeling at 25-3 but Tom Latham made 45 and Watling produced a fighting 50 to stretch New Zealand's lead to 177 runs with three wickets in hand at stumps.
William Somerville was batting on five at the other end when bad light stopped play at the Galle International Stadium.
Earlier, Sri Lanka added 40 runs to their overnight score of 227-7 before losing their last three wickets in the morning session.
New Zealand, who made 249 in the first innings, were undone by the Sri Lankan spinners in their second spell as well.
Off-spinner Dhanjaya de Silva drew first blood when Jeet Raval (four) was caught in the cover after trying to check his drive shot.
Kane Williamson had fallen for a third ball duck in the first innings and he looked uncharacteristically ill at ease in the second as well.
The right-hander made four before charging out against Lasith Embuldeniya and Kusal Perera, positioned at mid-on, took a superb catch leaping backward to send back the New Zealand skipper.
In his next over, Lasith Embuldeniya dismissed Ross Taylor (three) to further peg back the tourists.
Latham staged a brief recovery job with Henry Nicholls who contributed 26 before both departed. Watling then took it upon himself to stretch their lead.
The wicketkeeper-batsman hit five boundaries in his patient knock while Tim Southee chipped in with 23.