Pakistan took two Sri Lanka wickets in the final session on day four of the first Test in Galle, with the hosts trailing by 54 runs going into the final day.
Pakistan were 390-8 at tea and were able to add 27 more runs in the evening session before being bowled out for 417, 117 runs ahead of the hosts.
Kaushal Silva made a century in the first innings, but was only able to reach five today before he edged a Wahab Riaz delivery into the slips.
Other opener Dimuth Karunaratne, who remains at the crease unbeaten on 36, put on 45 runs with Kumar Sangakkara for the second wicket, but the partnership was broken shortly before the close of play when Sangakkara (18) was removed by Yasir Shah.
Sri Lanka are 63-2 going into the final day, with Karunaratne joined by Dilruwan Perera, who is yet to score. Pakistan need to take eight wickets and then quickly score if they are to sneak victory, meaning that a draw is the most likely outcome on the final day.