Younis Khan smashed 177 during a valiant fightback with the lower-order batsmen as Pakistan gained the upper hand in the first Test against Sri Lanka in Galle on Thursday.
Younis, who came in to bat at 19-2 on the first morning, anchored the innings admirably to enable the tourists to pile up 451 all out by tea on the second day.
Sri Lanka replied with 99-1 by close, comfortably tackling both pace and spin, but the batsmen will remain wary of the turn and bounce that will increasingly come into play over the next three days.
Left-arm seamer Junaid Khan trapped Upul Tharanga leg-before for 19 in the fifth over, but Kaushal Silva and Kumar Sangakkara settled in to put on 75 for the second wicket.
Silva was unbeaten on 38 and Sangakkara was on 36 with Sri Lanka still 352 runs behind the tourists.
The 36-year-old Younis, who is playing his 90th Test, batted for eight hours and 16 minutes, hitting 15 boundaries and a six in his 24th Test century.
The visitors added 32 runs in the first hour when left-arm spinner Rangana Herath broke through for Sri Lanka by trapping Shafiq leg-before. The batsman's appeal to the TV umpire went in vain.
Sri Lanka came close to removing Khan when he was on 156, but seamer Shaminda Eranga spilled a sharp return catch as the batsman failed to keep a drive along the ground.
Off-spinner Dilruwan Perera, who had gone without a wicket for four sessions, struck five times in the post-lunch period to hasten the end of Pakistan's innings.
Perera ended Khan's vigil soon after lunch by beating the well-set batsman in the air, resulting in an easy catch at short mid-wicket, a soft dismissal that came against the run of play.
Pakistan's wicketkeeper Sarfraz Ahmed made 55 and shared a sixth-wicket stand of 66 with Khan when he too lobbed an easy catch to mid-on to give Perera his second wicket.