Asad Shafiq's seventh hundred and a belligerent 96 from Sarfraz Ahmed helped give Pakistan a sizeable lead against Sri Lanka on the fourth day of the opening Test at Galle.
Sri Lanka had hoped for quick wickets in the morning when Pakistan resumed on 118 for five but a sixth-wicket stand of 139 between Sarfraz and Asad Shafiq (131) put paid to their chances.
Another 101-run stand for the ninth wicket between Shafiq and Zulfiqar Babar (56) gave the visitors the upper hand in the match.
Pakistan were finally all out for 417 with a first-innings lead of 117.
The tourists then piled on the pressure and picked up two wickets in the remainder of the day's play as Sri Lanka reached stumps on 63-2 in their second-innings, still trailing by 54 runs.
Kaushal Silva (five), a centurion in the first-innings, and the experienced Kumar Sangakkara (18) were the batsmen out.
Opener Dimuth Karunaratne (36) and nightwatchman Dilruwan Perera (nought) were at the crease for the hosts.
Sri Lanka 300 all out & 63-2 (Karunaratne 36*, Riaz 1-11)
Pakistan 417 all out (Shafiq 131, Perera 4-122)