Opener Dimuth Karunaratne top-scored with 130 as leg-spinner Yasir Shah claimed four wickets, while Azhar Ali and Rahat Ali took two each.
The series is tied at 1-1 after Pakistan won the first Test in Galle by 10 wickets and Sri Lanka took the second in Colombo by seven wickets.