Sri Lanka crawled to 133-5 for an overall lead of 220 runs as Pakistan pushed its bid to square the series on the fourth day of the third test on Sunday.
Sri Lanka lost the vital wicket of Mahela Jayawardene (46) off 144 balls just before the close after Pakistan was bowled out for 341 and conceded an 87-run first innings lead.
Captain Angelo Mathews was holding the fort on 14 and Prasanna Jayawardene was not out on 6, with both batsmen surviving dropped catches.
Left-arm spinner Abdul Rehman (2-36) got the two crucial wickets of Kaushal Silva and Kumar Sangakkara while fast bowler Mohammad Talha (2-36) removed Dinesh Chandimal. Jayawardene was caught close to the wicket off Saeed Ajmal just before stumps were drawn for the day.
"We just need five more wickets quickly so I think it's very important first hour tomorrow," Pakistan coach Dav Whatmore, who will leave the job after the third test, said.
"Every game we play, we play to win so we will go all out to do the best we can to achieve that result."
Pakistan could have had Mathews on 9 but Khurram Manzoor dropped a simple catch of the Sri Lanka captain's loose drive off Junaid Khan in the cover with Sri Lanka leading by 198 runs.
The dropped chance could prove costly for Pakistan. In the first innings Talha had dropped a difficult catch off Mathews from his own bowling on zero before the Sri Lankan captain went on to score 91.
Wicketkeeper Sarfraz Ahmed could not hold onto a legside catch off Prasanna Jayawardene's gloves before the batsman had scored to deny Ajmal his second wicket.
"Obviously we built a partnership and increased our lead so that we are out of danger, the pitch is taking turn but it's not very sharp," Sri Lanka's fast bowler Shaminda Eranga, who earlier took career-best 4-60, said.
Pakistan had a sniff when Talha clean bowled Chandimal in the first over after tea to reduce Sri Lanka to 89-4.
But Mathews and Jayawardene dug in and added 38 runs at a snail's pace with Pakistan spinners getting slow turn off the wicket.
Rehman tied down the scoring rate in Pakistan's most productive session after lunch as Sangakkara tried to cut loose in frustration but top-edged a sweep in the deep to Manzoor.
Rehman came close to dismissing Jayawardene lbw on 7, as Pakistan went for the television referral only to see that the ball would have missed the leg stump.
Jayawardene later became the first Sri Lankan to score 11,000 runs and the eighth batsman in test history to achieve the feat when he swept Ajmal for six and went to 14 before Rehman struck again.
Silva, who faced 94 balls and hit four boundaries, thought to have covered his stumps well but the ball spun enough after pitching to knock back the off stump.
Sri Lanka lost Dimuth Karunaratne (8) before lunch as the left-hander chopped Talha's short pitched delivery back onto his stumps when he completely mistimed the pull shot off the fast bowler under overcast conditions.
Earlier, Pakistan added 50 to its overnight 291-6 before Rangana Herath (5-125) and Eranga wrapped up Pakistan's first innings in just over an hour.
Captain Misbah-ul-Haq, 36 overnight, made 63 off 113 balls and tried to prolong the innings by mostly keeping the strike to himself before he finally holed out in the deep after hitting a four and three sixes off Herath.
Misbah farmed the strike and added 25 runs with Ajmal, who remained scoreless, after Eranga's twin strike had reduced Pakistan to 300-8.
Eranga struck in his first over when he had Rehman caught behind before having Talha trapped leg before wicket to surpass his previous career best figures of 4-65 against Australia at Colombo in 2011.
No. 11 batsman Junaid Khan brought the deficit to under 100 runs when he lofted Herath for two big sixes but then couldn't clear Chandimal at deep mid-wicket while repeating the same shot to give Herath his fifth wicket of the innings.
Who's the best test cricket captain?