The last two wickets added 59 runs after the hosts resumed at 261-8, with Chanaka Welegedara returning unbeaten on 27.
Opener Upul Tharanga top-scored with 92. Left-arm seamers Junaid Khan (five for 87) and Wahab Riaz (3-88) shared eight wickets.
Sri Lanka lead 1-0 in the two-match series after winning the first Test in Galle by seven wickets.