Sharja: Set a daunting 302 to win in a possible 59 overs, Pakistan owed their successful chase to Ali’s fifth Test century (103) as he and Misbah-ul-Haq shared a 109-run stand for the fifth wicket.
Misbah, who finished with 68 not out, hit the winning single with nine balls to spare in fading light.
Ali, ironically dropped for the first two Tests, hit paceman Suranga Lakmal for a boundary, then twice took two to reach his hundred off 133 balls.
He hit six boundaries before falling caught behind with just seven still needed to win.
Pakistan’s chances seemed to have faded away at 107-3 at tea, as they needed 195 in the last 35 overs. But Ali upped the tempo during a rapid 89-run partnership in 14.5 overs with Sarfraz Ahmed (48) which left Sri Lanka on the defensive.
Even when Sarfraz was out, caught behind off paceman Shaminda Eranga, Pakistan needed 116. Sarfraz hit four boundaries and a six off 46 balls.
But Misbah supported Ali as Pakistan achieved their second best chase in all Test cricket, behind the 314 they chased against Australia in Karachi in 1994.
Sri Lanka had won the second Test in Dubai by nine wickets while the first Test ended in a draw in Abu Dhabi.