Sri Lanka's former captain Kumar Sangakkara fell just short of another test cricket double century but thwarted Pakistan's hopes of victory as the second test ended in a draw.
Sangakkara was dismissed for 192 in the hosts' first innings but shared in a crucial 92-run sixth-wicket partnership with Angelo Mathews as Sri Lanka passed the follow-on mark before being dismissed for 391 just after lunch.
Pakistan then set Sri Lanka a daunting victory target of 261 from a minimum of 37 overs after their second turn at bat was closed two overs after tea at 100 for two.
The hosts ambled to 86 for two from 22 overs before captains Mahela Jayawardene and Misbah ul-Haq agreed to a draw.
Sri Lanka lead the three-test series 1-0.