Led by Ahmed Shehzad and Azhar Ali, Pakistan's batsmen put their first innings debacle behind them to get the team back into the second Test against Sri Lanka at the P Sara Oval in Colombo on Saturday.
The tourists, who conceded a lead of 177 runs after being dismissed for 138 in the first innings, closed the third day's play at 171 for two in their second knock.
When bad light halted play an hour early, Pakistan trailed by just six runs with eight wickets in hand, promising a keen tussle between bat and ball over the next two days.
Sri Lanka, looking for a series-levelling win after losing the first Test in Galle, removed Mohammad Hafeez cheaply for eight before lunch, caught in the slips by Kumar Sangakkara off Angelo Mathews.
Opener Shehzad hit 69 during a second-wicket stand of 120 with Ali, the pair batting through the post-lunch session to defy the Sri Lankan bowlers. Shehzad was dismissed off the first ball after tea, top-edging a hook off Dhammika Prasad, but Younis Khan joined Azhar to put on 42 for the unbroken third wicket. Azhar was unbeaten on 64 and Younis, determined to make his 100th match special after falling for six in the first innings, closed the day on a watchful 23.
Sri Lanka, who began at their overnight score of 304-9 after a delayed start due to bad weather, were dismissed for 315 in their first innings in reply to Pakistan's 138. Leg-spinner Yasir Shah finished with figures of six for 96 after last man Dushmantha Chameera was caught superbly by Younis running back from the slips, leaving Rangana Herath unbeaten on 18.
Yasir had claimed seven wickets in Sri Lanka's second innings in Galle to fashion Pakistan's 10-wicket victory in the first Test.
Sri Lanka were dealt a scare in the field when Chameera, the debutant seamer, went off the field in the morning session after sending down just nine deliveries. But he returned after lunch to bowl seven more overs and conceded 28 runs without any success. Veteran left-arm spinner Rangana Herath was also wicketless in 14 overs, while Prasad returned with one for 46 from 13.3 overs.
The third and final Test starts in Pallekele on July 3.