Pakistan remained on course for victory in the opening Test against Sri Lanka despite a top-order wobble chasing a meagre victory target of 131 at Galle on Wednesday.
Babar Azam's side had been in charge after claiming a handy first-innings lead of 149 in the first match of the two-Test series.
Their spin trio of Noman Ali (3-75), Abrar Ahmed (3-68) and Agha Salman (2-39) further consolidated their position by bowling out Sri Lanka for 279 in their second innings.
For the home side, Dhananjaya de Silva followed his first-innings hundred with 82, Nishan Madushka made 52 and Ramesh Mendis contributed 42 before they were all out.
Pakistan finished day four on 48-3 and will need 83 runs when play resumes on Thursday to go 1-0 up in the series.
Babar was batting on six with opener Imam-ul-Haq on 25 at the other end.
Sri Lanka's left-arm spinner Prabath Jayasuriya dismissed Abdullah Shafique and Shan Masood and then ran out nightwatchman Noman Ali to at least prevent it from being a cakewalk for Pakistan.
'I can't fight with anyone'
Big gains for Rohit and Jaiswal in ICC Test rankings
India eye series sweep in iconic 100th Test
'Tu humko de, bhai, sau run de ke'
Say Cheese! Lucky Day For India Fans