Pakistan were 107-3 at tea, needing another 195 in the remaining 35 overs or bat out for a draw.
At tea Azhar Ali (29) and Sarfraz Ahmed (seven) were at the crease.
Set a daunting 302 to win in a possible of 59 overs, Pakistan lost Ahmed Shehzad (21), Khurram Manzoor (21) and Younis Khan (29) and were derailed in their chase.
That means Sri Lanka are favourites to take the three-match series 1-0 after winning the second Test in Dubai by nine wickets. The first Test ended in a draw in Abu Dhabi.
Younis Khan tried to increase the pace but was caught off Angelo Mathews, two overs before tea.
Earlier, Sri Lanka were bowled out for 214 in their second innings, with left-arm spinner Abdul Rehman finishing with 4-56 and off-spinner Saeed Ajmal taking 3-53, but not before their batsmen had kept Pakistan at bay on the morning of the fifth and final day.