Younis Khan and Misbah-ul-Haq steadied the Pakistan second innings with an unbroken 113-run stand after their team appeared to be heading for a heavy defeat by losing three quick wickets in the second Test against Sri Lanka in Dubai on Friday.
At stumps on the third day, Pakistan reached 132 for three wickets, still trailing their opponents by 91 runs, with Younis (62) and Misbah (53) unbeaten at the crease.
Resuming on 318 for four, Sri Lanka were all out for 388 in their first innings in the morning, losing their last six wickets for 68 runs.
Pakistan's second innings started abysmally as left-arm spinner Rangana Herath dismissed opener Ahmed Shehzad at the stroke of lunch and paceman Nuwan Pradeep struck twice early in the afternoon to reduce them to 19 for three.
That brought Younis, who completed his 28th half century in Tests, and captain Misbah together and the pair went about carefully in their rescue mission.
Misbah was lucky to survive a couple of run-out chances but looked solid on the way to his 23rd Test fifty.
Earlier, Angelo Mathews (42), who was dropped by wicketkeeper Sarfraz Ahmed off Rahat Ali on Thursday evening, edged a similar delivery from the same bowler in the morning.
Sarfraz made no mistake this time, diving to complete the catch, and the Sri Lanka captain departed without adding to his overnight score after a 93-run stand with Mahela Jayawardene.
Jayawardene, running out of partners, went for some quick runs and was bowled on 129, trying to play a reverse sweep against Saeed Ajmal.
During the course of his innings, the stylish right-hander passed Australian Steve Waugh to move to number eight on the list of highest run-scorers in Tests. Waugh had scored 10,927 runs, while Jayawardene's tally stands at 10,940.
Pakistan 1st innings 165
Sri Lanka 1st innings (overnight 318-4)
D. Karunaratne lbw b Junaid 32
K. Silva lbw b Hafeez 95
K. Sangakkara lbw b Ali 26
D. Chandimal c Ali b Junaid 12
M. Jayawardene b Ajmal 129
A. Mathews c Ahmed b Ali 42
P. Jayawardene b Junaid 9
R. Herath run out 6
S. Eranga b Bhatti 14
S. Lakmal not out 10
N. Pradeep lbw b Ajmal 3
Extras: (b1, lb7, nb1, w1) 10
Total: (all out; 134 overs) 388
Fall of wickets: 1-40, 2-75, 3-88, 4-227, 5-320, 6-341, 7-348, 8-365, 9-377
Bowling: Junaid 36-7-102-3, Ali 36-6-131-2, Ajmal 34-11-56-2, Bhatti 22-3-80-1, Hafeez 6-1-11-1
Pakistan 2nd innings
Khurram Manzoor c Prasanna b Pradeep 6
Ahmed Shehzad c Prasanna b Herath 9
Mohammad Hafeez c Prasanna b Pradeep 1
Younis Khan not out 62
Misbah-ul Haq not out 53
Extras: (lb1) 1
Total: (for three wkts; 49 overs) 132
Fall of wicket: 1-11, 2-12, 3-19.
Bowling: Lakmal 6-1-19-0, Pradeep 10-2-28-2, Herath 21-3-58-1, Eranga 12-3-26-0.
Image: Younis Khan and Misba-ul Haq
Photograph: Marty Melville/Getty Images