Pakistan lost opener Sami Aslam in a shaky start to their tough 317-run target chase as they were 15-1 at tea on the fourth day of the second day-night Test in Dubai on Monday.
At the break Azhar Ali (nine) and Shan Masood (three) were at the crease with Pakistan still needing another 302 runs to win the match and level the two-match series.
Aslam, dismissed off a no-ball by pacer Lahiru Gamage, failed to take advantage of the chance as two balls later he was out for three to the same bowler.
Ali and Masood both survived confident leg-before appeals as Sri Lankan pacers attacked from the start.
Earlier, paceman Wahab Riaz grabbed 4-41 and left-arm spinner Haris Sohail took 1-3 to dismiss Sri Lanka for 96 in their second innings after they resumed at 34-5.
Pakistan needed early gains and Riaz provided them with the important wicket of Niroshan Dickwella in the fifth over of the day for 21.
Leg-spinner Yasir Shah dismissed Dilruwan Perera for nought to leave Sri Lanka in danger of being dismissed for their lowest ever total of 71 against Pakistan.
But Kusal Mendis (29) and Rangana Herath (17) added 35 for the eighth wicket to frustrate Pakistan before Sohail struck thrice in his only over to give his team hope of an upset win.
Shah finished with 2-47..
Sri Lanka won the first Test by 21 runs in Abu Dhabi. Pakistan must win the Dubai Test to keep their unbeaten record in UAE intact. (AFP)