In order to maintain their chances of winning the second Test on Wednesday and tying the series, Sri Lanka set Pakistan a record-breaking target of 508 and then held them to 89-1.
The hosts were robbed of valuable time when they declared their second innings on 360-8 because only six overs could be bowled during the final session before poor lighting forced a halt to play.
Imam-ul-Haq, Pakistan’s opener, was batting on 46 at the time of stumps, 419 runs off the impossible target.
The onus would be on Pakistan skipper Babar Azam, who is batting on 26, to help his team bat out the final three sessions for a draw, which would also secure the tourists a 1-0 series victory.
West Indies hold the record for the most successful fourth innings chase in Tests, having defeated a target of 418 in an Antigua Test in 2003.
Earlier, Dhananjaya de Silva hit 109, his ninth Test century, to help Sri Lanka maintain their lead at the Galle International Stadium.
Sri Lanka
After Sri Lanka resumed on 176-5, home captain Dimuth Karunaratne (61) overcame lower back pain to put on a 126-run stand with de Silva.
After a barren first hour, Nauman Ali struck with a sharp, reflex catch at short leg to remove Karunaratne, the sixth Sri Lankan batter to reach 6,000 Test runs.
De Silva reached his century with a boundary off Mohammad Nawaz and was well supported by tailender Ramesh Mendis, who was not out on 45.
Sri Lanka declared immediately after de Silva exited the field.
Pakistan got off to a good start with Shafique and Imam before Prabath Jayasuriya broke the 42-run opening stand.
Shafique charged out against the spinner but was unable to connect well, sending the ball to mid-off, where Dunith Wellalage ran sideways with his eyes on the ball and took a tumbling catch.