Saud Shakeel and Agha Salman struck defiant half-centuries to help Pakistan overcome Prabath Jayasuriya's onslaught and just about keep the tourists on course to match Sri Lanka's first-innings 312 on day two of the opening Test in Galle on Monday.
Pakistan bowled out Sri Lanka in the morning session, but Dhananjaya de Silva (122) was able to complete his century as the hosts added 70 runs to their total after resuming on 242-6.
Pakistan's first innings started poorly with opener Imam-ul-Haq dismissed cheaply for just one run, after he holed out to backward point.
Wickets fell at a steady rate thereafter, with Jayasuriya striking three times, claiming the wickets of Abdullah Shafique, Babar Azam and Sarfaraz Ahmed to leave Pakistan struggling at 101 for five.
However, the see-saw contest changed complexion in the final session following a 120-run partnership between Saud and Salman.
Saud was unbeaten on 69 with Salman on 61, as rain brought the day's play to a premature end with Pakistan at 221-5.