Pakistan sense victory despite top order wobble in small chase
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.