Thilan Samaraweera hit a half-century under pressure to lead Sri Lanka's recovery on the third day of the second and final Test against New Zealand at the P Sara Oval in Colombo.
Sri Lanka were in big trouble on 5-103 before finishing Tuesday on 6-225 in reply to New Zealand's first-innings 412, thanks to the middle-order batsman's defiant 76 not out off 156 deliveries.
Samaraweera, who had injured his finger while fielding, received valuable support from lower-order batsman Suraj Randiv who made a resolute 102-ball 34 not out, his highest score in 12 Tests.
The pair have so far added 97 and helped their team avoid the follow-on. But the tourists were in control when bad light stopped play with 25.4 overs remaining in the day.
Sri Lanka, leading the series 1-0 following their 10-wicket win in the opening Test, are still 187 behind with four wickets in hand.
Fast bowler Tim Southee, who took two wickets in an over on Monday, had Sri Lanka - resuming on 3-43 - in trouble in the morning when he struck twice before Samaraweera and Randiv steadied the innings.
Angelo Mathews and opener Tharanga Paranavitana put on 90 after three wickets had fallen for just 12 on Monday but Southee dismissed them in successive overs.
Paranavitana (40) edged the paceman to wicket-keeper Kruger van Wyk while Mathews (47) fell to a superb one-handed catch by Martin Guptill, who held the ball low to his right in the slips.
New Zealand had wasted an earlier chance to break the fourth-wicket stand when skipper Ross Taylor dropped Paranavitana at first slip off fast bowler Trent Boult when the batsman was on 32.
Mathews played some aggressive shots in the morning, lofting off-spinner Jeetan Patel over wide long-on for the first six of the innings and then cutting the bowler past point for four.
Southee has so far taken four wickets for 51 off 19 overs.