Pakistan were reduced to 48 for five wickets at stumps on day two of the first Test in reply to Sri Lanka's commanding first innings total of 472 all out on Saturday.
Pakistan's batsmen crumbled in a disastrous final session at the Galle International Stadium and remain 424 runs behind Sri Lanka, needing a further 225 runs to avoid the follow-on.
Sri Lanka's Kumar Sangakkara narrowly missed out on his ninth double hundred as he was left stranded on 199 after six hours at the crease.
Sangakkara was joined by Nuwan Pradeep when he was on 182. Having shielded the strike from the last man, Sangakkara hit Saeed Ajmal for a six over mid-wicket and celebrated after the scoreboard wrongly indicated that he had reached his double century.
Sangakkara then pushed the last ball of the over to covers but couldn't get the single for the strike. In the next over Pradeep was bowled by Mohammad Hafeez and former Sri Lanka captain Sangakkara joined Zimbabwe's Andy Flower as the second Test cricketer to be left stranded on 199.
Off-spinner Ajmal finished with 5-146, his sixth five wicket haul in Test cricket. Hafeez supported him well in claiming three wickets.
Earlier Sangakkara added 128 runs for the third wicket with Mahela Jayawardene, who made 62 runs before falling to Ajmal.
Sangakkara completed 2,000 runs against Pakistan. Only Sunil Gavaskar of India has scored more runs in Tests against Pakistan.
Nuwan Kulasekara put Pakistan on the back foot when he picked up the wickets of Taufeeq Umar (9) and Azhar Ali (0) in successive balls to reduce the visitors to 12-2.
Off-spinner Suraj Randiv dismissed stand-in captain Mohammad Hafeez (20) and nightwatchman Ajmal (0) in successive deliveries before Rangana Herath had Asad Shafiq caught behind without scoring.