New Zealand spinner Ajaz Patel claimed a second Test five-for but Niroshan Dickwella and Suranga Lakmal came to Sri Lanka's rescue as 12 wickets fell on day two of the first Test in Galle.
The excellent Akila Dananjaya (5-80) and Lakmal (4-29) wasted no time in dismissing the tourists for 249 in the morning session after they had resumed on 203-5, Ross Taylor failing to add to his overnight score of 86.
Half-centuries from Kusal Mendis (53) and Angelo Mathews (50) put Sri Lanka in a promising position, but Patel (5-76) generated sharp turn as Dimuth Karunaratne's side collapsed to 161-7 losing five wickets for 18 runs.
Dickwella (39 not out) and Lakmal (28 not out) ensured the first of two Tests was finally poised at stumps, though, seeing Sri Lanka through to 227-7 - a deficit of just 22 runs.
Taylor fell off the first ball he faced on the second day edging Lakmal behind with a loose stroke, and the paceman struck again by trapping Mitchell Santner leg before.
Tim Southee came down the track to dispatch Dhananjaya de Silva over the ropes, but was run out later in the over.
Trent Boult - who had the ball lodged in his helmet after attempting a sweep - added a useful 18 before Lakmal polished off the tail as the tourists lost their last five wickets for 44 runs.
Lahiru Thirimanne gifted the Black Caps a breakthrough when he was stumped giving Patel the charge in his first over and Karunaratne could have followed in the next over from William Somerville, but Taylor put him down at first slip.
Sri Lanka took lunch on 34-1 and Karunaratne (39) looked in good touch until he was snared lbw by the probing Patel with 66 on the board.
Kusal and Matthews played positively against the spinners, hitting Somerville and Santner respectively for six as they put on 79 for the third wicket.
A lapse in concentration cost Kusal on the stroke of tea, though, the right-hander wafting at a flighted delivery from Patel immediately after reaching his half-century and offering Taylor a simple slip catch.
That sparked a collapse, with Boult getting rid of Kusal Perera and De Silva also failing before Patel secured his fifth wicket by getting one to turn away from Mathews, who edged to Taylor at slip.
Somerville sent Dananjaya on his way for a duck as the procession of wickets continued, but Dickwella and Lakmal provided much-needed resistance with an unbroken stand of 66 to give Sri Lanka a great chance of taking a first-innings lead.
- VIDEO: Djokovic celebrates U.S Open triumph with Serbian basketball team
- King’s Cup 2023: Litmus test for India to find its next No. 9 with FIFA World Cup 2026 qualifiers ahead
- VIDEO: I was a little a nervous on my comeback, says KL Rahul
- Danke Seb - Sebastian Vettel bids farewell to F1 after fabled career
- Indian sailing team headed to Newport USA for World Championships