Kumar Sangakkara led Sri Lanka's fightback in the second innings with an unbeaten 161, aided by sloppy Pakistan fielders who dropped a number of catches on day four of the first Test in Abu Dhabi.
At stumps on the penultimate day of the Test, Sangakkara and Prasanna Jayawardene (25) were at the crease with Sri Lanka on 298 for five wickets, still trailing Pakistan by 16 runs.
The duo added 65 for an unbroken sixth-wicket stand and Sri Lanka's hopes of saving the match rest on them extending their partnership on the final day.
Former captain Sangakkara, who has hit 16 boudaries so far in his 295-ball knock, reached the three-figure mark with a square driven four off left-arm paceman Junaid Khan.
Umar Gul removed Angelo Mathews (22) lbw with the first delivery with the second new ball but Pakistan's chances of a victory were hurt by the profligacy of their fielders.
Mohammad Hafeez dropped Thirimanne (68) three times, twice off successive deliveries off Junaid Khan and again off spinner Saeed Ajmal.
Hafeez was the unlucky bowler when Younis Khan, at slip, dropped a tough chance of Sangakkara, when he was on 56.
Prasanna Jayawardene, when on 12, was also provided a life when substitute fielder Wahab Riaz put down a straightforward chance off Umar Gul at short mid-wicket.
Junaid, who took his maiden five-wicket haul in the first innings, bowled an inspiring spell in the morning and also found Sangakkara's edge, which Younis managed to hold on to.
However, the umpires ruled the batsman not out after television replays suggested that the ball might have hit the ground before Younis took the catch.
Pakistan picked the wickets of experienced Mahela Jayawardene (four) and captain Tillakaratne Dilshan (nine) in the afternoon session to boost their chances.
Pakistan are playing "home" Tests in the Gulf region because of security fears in their own country. The match is the first in a three-Test series.
Scorecard
Sri Lanka (1st innings): 197
Pakistan (1st first innings): 511-6 declared
Sri Lanka (2nd innings): (overnight 47-1)
T Paranavitana lbw b Umar Gul 0
L Thirimanne run out 68
K Sangakkara not out 161
M Jayawardene b Saeed Ajmal 4
T Dilshan b Junaid Khan 9
A Mathews lbw b Gul 22
P Jayawardene not out 25
Extras: (b-3, lb-5, nb-1) 9
Total: (for five wickets; 101 overs) 298
To bat: R. Herath, S. Lakmal, C. Welegedara, N. Pradeep.
Fall of wickets: 1-0 2-153 3-160 4-191 5-233.
Bowling: Umar Gul 15-2-49-2 (1nb), Aizaz Cheema 17-0-66-0, Saeed Ajmal 36-7-100-1, Junaid Khan 17-2-43-1, Mohammad Hafeez 16-2-32-0.
Sri Lanka reel under Umar's maiden 200
Junaid Khan's maiden five-wkt haul wrecks Sri Lanka
Shah Rukh Khan: The Lover Or The Superhero?
Two new balls rule boon for fast bowlers: Vinay Kumar
Hockey 9s: India, Pakistan in thrilling draw