Pakistan chased down 302 in two sessions to win the third Test against Sri Lanka and draw the series 1-1.Sri Lanka began the day on 133-5 but were bowled out for 214, losing their last five wickets for 25 runs.
Pakistan had 59 overs to reach their target and their top order scored at 4.45 an over in the afternoon.
Azhar Ali scored 103 and, even though he fell in fading light, captain Misbah-ul-Haq scored the winning runs to complete a five-wicket victory.
The win was secured with nine balls to spare and was Pakistan’s second highest chase in Tests, their best being the 315-9 to beat Australia in Karachi 20 years ago.
The series in the United Arab Emirates marked coach Dav Whatmore’s farewell after his contract was not renewed.
“This is my best moment as captain,” said Misbah, who scored an unbeaten 68 from 72 balls in the second innings.
“We really wanted to win, especially for Dav. We wanted to win it for him and level the series.
“We really enjoyed being with him for these two years.”