Pakistan lost three wickets in a tricky 131-run chase on day four of the rain-hit opening Test against Sri Lanka on Wednesday.
That came after spinners Noman Ali and Abrar Ahmed helped bowl Sri Lanka out for 279.
The tourists reached 48-3 at stumps in Galle, needing another 83 to take the lead in the two-match series.
Imam-ul-Haq, on 25, and captain Babar Azam, on six, were at the crease.
Left-arm spinner Prabath Jayasuriya struck twice with the wickets of Abdullah Shafique, caught behind for eight, and Shan Masood for seven.
Noman was sent in as nightwatchman but he was run out on nought.
Sri Lanka’s first-innings centurion Dhananjaya de Silva top-scored with 82 before the Pakistan bowlers combined to dismiss the hosts in the final session of the day.
Left-armer Noman and fellow spinner Abrar took three wickets each and, along with Agha Salman’s two wickets, struck regular blows.
Pace spearhead Shaheen Shah Afridi snared another two to help clean up the tail.
De Silva, who scored 122 in Sri Lanka’s first-innings total of 312, built key partnerships including a 76-run seventh-wicket stand with Ramesh Mendis, who made 42.
Shaheen, a left-arm quick, finally got De Silva caught behind with a rising delivery after Pakistan took the second new ball.
Shaheen got his second before Abrar ended the innings.
Salman sent back Dinesh Chandimal for 28 to break a 60-run stand with De Silva and then Samarawickrama for 11 to put Sri Lanka in trouble, but De Silva stood firm.
Abrar struck first earlier with his leg spin to send back captain Dimuth Karunaratne for 20 to check Sri Lanka’s brisk start.
Batsman Saud Shakeel has remained the star for Pakistan so far with his unbeaten first-innings 208 – his maiden Test double century – in his team’s 461 all out on day three.
Shakeel’s marathon knock handed Pakistan a handy lead of 149 as rain interrupted play on the first three days.
Rain stayed away on day four, which started late due to a damp patch on the field.
© Agence France-Presse