Debutant Fawad Alam hit a maiden Test century as Pakistan battled back against Sri Lanka on the second day of the second Test on Monday.
Opener Alam was unbeaten on 102 as Pakistan reached 178 for one in their second innings, a lead of 28 runs.
Pakistan were bowled out for 90 on the first day but their bowlers began the fightback on Monday, paceman Umar Gul taking 4-43 and off spinner Saaed Ajmal 4-87 as Sri Lanka, who had resumed on 164 for three, were bowled out for 240.
Having lost seven wickets for 76 runs, the hosts then saw their 150-run lead wiped-out during the afternoon as the 23-year-old left-hander Alam, who normally bats in the middle order, became the first Pakistani to score a century overseas on his Test debut.
Skipper Younus Khan will resume on 35 not out having added 93 for the second wicket with Alam, who has so far stroked six fours and one huge six over deep mid-wicket.
A day after the tourists were bundled out for their lowest score against Sri Lanka, Gul set about keeping Pakistan in the contest with a fine burst, including the prized scalp of Kumar Sangakkara for 87 who was removed by a fine delivery that cut back between bat and pad to bowl Sangakkara.
Sri Lanka's 150-run lead looked a potential match-winning cushion, but Alam and Khurram Manzoor batted with far greater application than in the first innings.
The new ball was negotiated without great alarm and the opening pair added 85 for the first wicket.
Finally, in a long evening session, left-arm spinner Rangana Herath broke through as wicketkeeper Tillakaratne Dilshan held onto a bottom edge off Manzoor (38).
Sri Lanka won the first match of the three-Test series by 50 runs.