Defiant batting from Tharanga Paranavitana and Kumar Sangakkara lifted Sri Lanka's hopes of turning the second Test their way here yesterday.
The Lions however still trail Pakistan by 76 runs after conceding a first-innings lead of 164.
Paranavitana compiled an unbeaten 42 off 141 balls in three hours as the Sri Lankans dug in while fellow left-hander Sangakkara fought his way to 29 not out off 86 deliveries.
Pakistan had earlier stretched their overnight 281 for 4 to 403 all out midway through the day. The hosts' innings had been built around Azhar Ali's century on the second day while Asad Shafiq (59) and wicketkeeper Adnan Akmal (41) consolidated Pakistan's advantage.
Shafiq led the hosts after they lost captain Misbah-ul-Haq (41) in yesterday's second over to Chanaka Welegedara. Misbah edged to second slip where Mahela Jayawardene pouched a nice catch. Shafiq, a pint-sized right-hander, then forged telling partnerships with Saeed Ajmal and Akmal to restore Pakistan's edge.
He added 41 with nightwatchman Ajmal, who contributed a useful 20. But once Shafiq steered a catch to Jayawardene at gully off seamer Dhammika Prasad, the innings folded swiftly as four wickets fell for nine runs. Shafiq's third Test half-century spanned 101 balls and was laced with four fours and a six.
Part-time off-spinner Tillakaratne Dilshan led the bowling with 3 for 57 while Prasad took 3 for 104. Welegedara (2 for 79) and Rangana Herath (2 for 89) completed the wicket-taking.
Sri Lanka, facing a large deficit, went to tea unscathed at 17 for 0 but Pakistan struck soon after the break through Mohammad Hafeez.
The emerging off-spinner claimed Lahiru Thirimanne with a delivery that turned past the outside edge to clip the off stump. But Pakistan were frustrated for the rest of the afternoon as Paranavitana and Sangakkara rode their luck.
Pakistan thought they had claimed Sangakkara for seven when he deflected Hafeez to leg slip but umpire Shavir Tarapore ruled in the batsman's favour.