Dinesh Chandimal remained unbeaten on 94 as Sri Lanka were bowled out for 337 on day four of the opening Test on Tuesday, leaving Pakistan needing 342 runs for victory.
Pace bowler Naseem Shah bowled Prabath Jayasuriya for four early in the morning session after the hosts resumed the day on 329 for nine in Galle.
Mohammad Nawaz, an all-rounder who bowls left-arm spin, returned figures of 5-88 after taking his maiden five-wicket haul on Monday, while fellow spinner Yasir Shah took three wickets.
The Pakistan spinners had reduced Sri Lanka to 235-7 but Chandimal hit back with his second half-century of the match and got help from the tail to hand the tourists a challenging target.
Chandimal, who hit 76 in Sri Lanka’s first innings total of 222, put on key partnerships including a 41-run ninth-wicket stand with Maheesh Theekshana.
Opener Oshada Fernando (64) and Kusal Mendis (76) also struck key knocks, putting on 91 runs for the third wicket to add to Sri Lanka’s dominance on a turning pitch.