Sri Lanka had resumed the day on 315-6 in former captain Angelo Mathews’ landmark 100th Test.
Ramesh Mendis led an inspired Sri Lanka spin attack to leave Pakistan in trouble at 191-7 in reply to the hosts’ 378 on day two of the second Test on Monday.
The tourists, who lead the two-match series 1-0, ended the day still trailing Sri Lanka by 187 runs in their first innings at Galle.
Agha Salman resisted the bowling attack with his maiden Test fifty but fell to Prabath Jayasuriya’s left-arm spin for 62 in the final moments of play before stumps was called.
Jayasuriya got Salman caught at slip with a drifter coming into the right-handed batsman.
Salman, who made his debut in the previous match, put on 46 runs with Yasir Shah, batting on 13, to lift Pakistan from 145-6.
Ramesh rattled Pakistan’s middle-order with his off-spin bowling on a pitch expected to turn more from day three onwards.
Pakistan suffered from a lack of partnerships after losing first-match hero Abdullah Shafique for a duck and skipper Babar Azam for 16 on either side of the lunch break.
Jayasuriya, who took 21 wickets in his first two Tests, bowled Azam on a turning delivery that got the edge of the dangerman’s bat to crash onto the stumps.
Imam-ul-Haq attempted to rebuild the innings with Mohammad Rizwan but Dhananjaya de Silva broke through with his off-spin to send back Imam on 32.
De Silva is standing in as captain in place of Dimuth Karunaratne, who did not take the field in the Pakistan innings because of back pain.
Rizwan hit a few boundaries to counterattack but Ramesh trapped him lbw for 24 and a review did not help the wicketkeeper-batsman, with replays showing the ball would have hit leg stump.
Pakistan had lost opener Shafique, who hit a match-winning 260 in the first Test, when he inside-edged a delivery from Asitha Fernando onto his stumps.
Wickets kept tumbling but all-rounder Salman, who went wicketless in his six overs in Sri Lanka’s innings, played the spinners on the front foot until his departure.
Sri Lanka had resumed the day on 315-6 in former captain Angelo Mathews’ landmark 100th Test, with overnight batsman Niroshan Dickwella making 51 and a useful cameo of 35 by Ramesh at number nine.
Fast bowler Naseem Shah and leg-spinner Yasir claimed three wickets each to end Sri Lanka’s innings in the first session.