Asad Shafiq and Sarfraz Ahmed hit fighting half-centuries on Monday to thwart Sri Lanka and set up an enthralling finish to the second and final day-night Test in Dubai.
Shafiq scored an unbeaten 86 while skipper Ahmed was 57 not out as they lifted Pakistan from a perilous position at 52-5 to 198-5 at close after being set a daunting target of 317.
The pair added 146 for the unbroken sixth-wicket stand to leave Pakistan needing another 119 runs with five wickets in hand to level the series.
Sri Lanka won a nail-biting first Test in Abu Dhabi by 21 runs.
Both Shafiq and Ahmed batted confidently to raise hopes of Pakistan maintaining their unbeaten record in nine Test series in the United Arab Emirates, their adopted home since 2009.
Pakistan have been forced to play at a neutral venue since a 2009 terror attack on the Sri Lankan team prompted authorities to suspend international cricket in the country.
Earlier, paceman Wahab Riaz grabbed four for 41 and left-arm spinner Haris Sohail took three wickets in a single over to dismiss Sri Lanka for 96 in their second innings, after they resumed on 34-5.