Sri Lanka mounted a resilient rearguard to stave off an innings defeat and frustrate Pakistan on Thursday, reaching 309-9 on day three of the second and final Test in Rawalpindi.
Milan Rathnayaka hit an unbeaten 60 while Sonal Dinusha (54) and Kusal Mendis (53) defied Pakistan's pace attack, avoiding an innings defeat and delaying a result.
At close, Asitha Fernando was the other unbeaten batter on two as the tourists batted in all three sessions to add 235 runs after resuming on 74-3.
The visitors now lead by 82 runs and will hope for a miracle to avoid a defeat or pull off a win.
Sri Lanka's fightback was aided by a hamstring injury to Pakistan fast bowler Saqib Khan, who was unable to bowl on Thursday, weakening the hosts' attack as the Pindi Stadium pitch became easier to bat on.
On 167-5 at lunch, Sri Lanka were staring at an innings defeat, but Dinusha and Sri Lanka skipper Kusal put on a fighting 81-run stand for the sixth wicket, leaving Pakistan frustrated.
Kusal hit a miscued sweep off spinner Salman Agha onto his stumps, trudging off in disappointment. He hit eight boundaries in his 24th Test half-century.
Dinusha and Rathnayaka then prolonged the fight as the duo erased Pakistan's 227-run lead, adding 53 for the seventh wicket.
It was Aamer Jamal who broke the stand with the second new ball, getting Dinusha caught at mid-wicket by Azan Awais off a miscued pull shot.
Dinusha's resolute knock had seven boundaries.
Jamal was the pick of the bowlers with 3-67, while Mohammad Abbas took 2-54.
Earlier in the morning, Jamal had provided Pakistan with an early breakthrough when he trapped Dhananjaya de Silva (37) lbw with a sharp incoming delivery.
Razaullah also had Pasindu Sooriyabandara (38) caught brilliantly by wicketkeeper Ghazi Ghori diving to his left.