Pakistan lost three wickets in a tricky 131-run chase on day four of the rain-hit opening Test on Wednesday to give Sri Lanka a glimmer of hope in the contest.
The tourists reached 48-3 at stumps in Galle, needing another 83 on the fifth and final day to take the lead in the two-match series.
Pakistan spinners Noman Ali and Abrar Ahmed took three wickets each to help bowl out Sri Lanka for 279 in the final session despite a stubborn 82 by first-innings centurion Dhananjaya de Silva.