Sri Lanka stumbled to stumps at 69-4 Sunday in its second innings to lead by only 66 runs as Pakistan dominated Day 4 of the first test.
Kusal Mendis was 16 not out and Suranga Lakmal undefeated on 2. Pakistan's Yasir Shah had 2-25 off 14 overs to set up an uncomfortable last day for Sri Lanka which has a vulnerable tail.
Earlier, Pakistan took a three-run first-innings lead after reaching 422 all out.
Pakistan trailed Sri Lanka by 153 runs after resuming on 266-4. Azhar Ali moved on from his overnight 74 to only 85, before he was caught off Rangana Herath's delivery.
Left-arm spinner Herath finished on 5-93 off 40 overs.
Haris Sohail was the last man out for Pakistan with a defiant 76, including seven fours and two sixes.
Sri Lanka scored 419 in its first innings, which included a ninth test century from Dinesh Chandimal.