Sri Lanka set Pakistan a record target of 508 and then restricted them to 89-1 to keep alive their hopes of a series-levelling victory in the second test on Wednesday.
The hosts declared their second innings on 360-8 but were robbed of precious time as only six overs could be played in the final session before bad light stopped play.
Opener Imam-ul-Haq was batting on 46 at stumps with Pakistan 419 runs behind the improbable target.
The onus would be on Pakistan skipper Babar Azam, batting on 26, to help his team bat out the final three sessions for a draw that would also secure a 1-0 series victory for the tourists.
West Indies own the record for the highest successful fourth innings chase in tests having overwhelmed a target of 418 in a 2003 test in Antigua.
Earlier, Dhananjaya de Silva smashed 109, his ninth test hundred, to help Sri Lanka consolidate their position at the Galle International Stadium.
Home captain Dimuth Karunaratne (61) braved lower back pain to combine in a 126-run stand with de Silva after Sri Lanka resumed on 176-5.
After the barren first hour, Nauman Ali struck when Abdullah Shafique took a sharp, reflex catch at short leg to remove Karunaratne, who became the sixth Sri Lankan batter to score 6,000 test runs.
De Silva brought up his hundred with a boundary off Mohammad Nawaz and got good support from tail-ender Ramesh Mendis who remained not out on 45.
Sri Lanka declared immediately after de Silva ran himself out.
Shafique and Imam began well for Pakistan before Prabath Jayasuriya snapped the 42-run opening stand.
Shafique charged out against the spinner but could not connect well sending the ball to mid-off where Dunith Wellalage ran sideways while eyes on the ball to take a tumbling catch.


PSG retain Champions League title with shoot-out win over Arsenal
French Open champion Gauff knocked out by Potapova in third round
Sabalenka sees off Kasatkina to reach French Open fourth round
Parry stuns Anisimova to reach first Grand Slam fourth round at French Open
Osaka survives three-set scare against teenager Jovic