Younis Khan and Misbah-ul-Haq led a Pakistan rescue mission in the form of a 113-run partnership as they battled back against Sri Lanka in the second Test in Dubai.
The duo came together with their side on 19-3 and in grave danger of failing to make the 223 runs needed to make Pakistan bat again for the match.
But by the close Younis' 62 and Misbah's 53 had steered Pakistan to the relative comfort of 132-3 and 91 runs behind.
Pakistan got themselves into all sorts of trouble as Ahmed Shehzad (nine), Mohammad Hafeez (one) and Khurram Manzoor (six) all edged behind, with Rangana Herath taking one and Nuwan Pradeep two.
But Younis (41) and Misbah (27) got through to lunch with no further damage, still some 138 behind.
That break allowed them to take stock and they played diligently overall in the evening session, although Misbah only narrowly avoided a run-out on 41.
Earlier Mahela Jayawardene passed Steve Waugh as Test cricket's eighth all-time leading run scorer, moving from his overnight 106 to 129 as his side were bowled out for 388.
A collapse from 318-4 to that total was not a great achievement, but at least Jayawardene gave Sri Lankan fans something to cheer about.
He is now clear of the Australian great on 10,940 runs, but that tally could not protect him from being bowled by Saeed Ajmal in the morning session.
Also departing was Angelo Mathews, with the captain unable to add to his overnight 42 before he was snared by Rahat Ali.
Ali also threw down the stumps to run out Herath (six), with Prasanna Jayawardene cleaned up by Junaid Khan (nine). The innings quickly folded after that, with Shaminda Eranga going to Bilawal Bhatti and Nuwan Pradeep falling to Ajmal.