Tharanga Paranavitana compiled an unbeaten 42 off 141 balls in three hours. Fellow left-hander Kumar Sangakkara was equally defiant, fighting his way to 29 not out off 86 deliveries.

The pair, dealing with quality Pakistan spin bowling on a wearing pitch, shared an unbroken second wicket stand of 66 in two hours to leave Sri Lanka trailing by 76 runs.

Pakistan had earlier stretched its overnight 281-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 on day three.

Shafiq led the hosts after they lost captain Misbah-ul-Haq (41) in the day's second over to Chanaka Welegedara (2-79). Misbah edged to second slip where Mahela Jayawardene pouched a nice catch.

Shafiq, a pint-sized right-hander from Karachi, 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.

Ajmal, who was dropped by Angelo Mathews at gully off Welegedara when 14, eventually fell in the same fashion at 324-6. Shafiq and Akmal, similar in style and stature, ensured Pakistan pushed their lead to three figures with an enterprising stand either side of lunch.

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.

Abdur Rehman (0) swung wildly at Rangana Herath and was bowled while Umar Gul (2) fell lbw in the same over.

Akmal's resistance was ended by Tillakaratne Dilshan when he thin-edged through to wicketkeeper Kaushal Silva. Akmal cracked four fours off 80 balls in 105 minutes.

Part-time offspinner Dilshan led the bowling with 3-57 while Prasad took 3-104. Welegedara (2-79) and Herath (2-89) completed the wicket-taking.

Sri Lanka, facing a large deficit, went to tea unscathed at 17-0 but Pakistan struck soon after the break through Mohammad Hafeez (1-24).

The emerging offspinner claimed Lahiru Thirimanne (6) 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 along the way.

Pakistan thought they had claimed the veteran Sangakkara at 7 when he deflected Hafeez to leg slip but umpire Shahvir Tarapore ruled in the batsman's favor.

Sangakkara, unusually restrained against probing spin on a deteriorating pitch, went without a boundary in 86 balls and two hours.

Paranavitana collected two boundaries but also endured a difficult examination.

He was 20 when he charged left-arm spinner Rehman and wicketkeeper Akmal missed a very difficult stumping. The opener also survived a run out chance after a mix-up with Sangakkara, but substitute Shoaib Malik fluffed the opportunity with a wayward throw from cover.