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.