Pallekele: Azhar Ali's second century of the series lifted Pakistan to 299-8 but an overall lead of only 188 runs against Sri Lanka after four days of the third Test on Wednesday.
Ali, who made a century in the drawn second test, scored 136 off 284 balls and featured in two productive partnerships - adding 94 with opener Mohammad Hafeez (52) and another 100 with Asad Shafiq (55 not out).
Dilhara Fernando had Ali caught behind with the second new ball and then trapped Mohammad Sami lbw for his 100th wicket in tests.
But the pick of the Sri Lanka bowlers was left-arm spinner Rangana Herath with 4-64 that included the key wickets of Younis Khan and captain Misbah-ul-Haq.
Sri Lanka, who won the first Test in Galle before the second in Colombo was drawn, need only a draw to secure their first series victory in three years since beating New Zealand 2-0 at home in 2009.
Azhar, who made 157 in the Colombo Test, held the innings together for close to five hours, hitting nine boundaries as he approached his fourth Test century.
The right-hander put on 94 for the second wicket with his overnight partner Mohammad Hafeez and 48 for the third with Younis Khan after Pakistan resumed the day at 27-1.
Hafeez, who also hit a century in Colombo, made 52 when he was dismissed just before lunch with Pakistan two runs away from wiping out the first innings deficit of 111 runs.
The Pakistan vice-captain edged a wild drive off fast bowler Dilhara Fernando to Tharanga Paranavitana in the slips.
Wicket-keeper Prasanna Jayawardene dropped a low catch when Younis, then on 12, followed a wide ball from Angelo Mathews.
But the missed chance did not prove costly as Younis managed to add just seven more runs when he was snapped up by a lunging Paranavitana at silly-point off Rangana Herath.
Brief scores
Pakistan 226 (Shafiq 75, Misbah 40, Perera 4-63) and 299 for 8 (Ali 136, Shafiq 55*, Hafeez 52)
Sri Lanka 337 (Paranavitana 75, Perera 75, Samaraweera 73, Junaid 5-70)
Status Pakistan lead by 188 runs