Azhar Ali hit a brilliant hundred as Pakistan pulled off a thrilling win in the third and final Test against Sri Lanka in Sharjah today, levelling the series 1-1.
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.
Pakistan had lost Ahmed Shehzad (21), Khurram Manzoor (21) and Younis Khan (29) as they were derailed in their chase.
Needing to score at a rate of more than five an over to win, Pakistan were given a rapid 35-run start by the sixth over but paceman Suranga Lakmal (3-79) halted that progress by dismissing openers Shehzad and Manzoor within 13 runs.
Younis Khan tried to increase the pace before being caught off Angelo Mathews two overs before tea, but the scenario changed in the last session.
With the series tied, Pakistan also remained unbeaten in five series in the United Arab Emirates, which has become their home since security fears -- sparked in the wake of attacks on the Sri Lankan team bus in Lahore in 2009 -- forced them to play at neutral venues.
They twice drew series with South Africa (2010 and 2013) and beat Sri Lanka (2011) and England (2012).
Misbah said Pakistan desperately wanted the win.
"That was really a much wanted win. We wanted the win it for our coach Dav Whatmore and wanted to give him a winning farewell," said Misbah of the team coach who ends his two-year tenure with this match.
Sri Lankan captain Angelo Mathews regretted batting failure.
"We dominated for three-and-a-half days but unfortunately could not score big in the second innings and lost," said Mathews, declared man-of-the-series for his 412 runs in three Tests.
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.
On an exciting day when both teams had a chance of victory, Mathews (31) and Prasanna Jayawardene (49) shared a 62-run stand for the sixth wicket and batted positively to add 56 in the first hour after the tourists resumed at 133-5.
But Mohammad Talha gave Pakistan their much-needed breakthrough when he had Mathews caught off a miscued hook.
Rehman then grabbed two quick wickets to put the brakes on Sri Lanka, having Dilruwan Perera caught at short-leg for eight before removing Rangana Herath for a first-ball duck.
Herath recorded a golden pair in the match as he was also dismissed first ball in the first innings.
Prasanna hit six boundaries in his 88-ball knock before he was dismissed by Ajmal, who also removed Shaminda Eranga to wrap up the innings.