Azhar Ali and Fawad Alam hit fighting half-centuries Wednesday to lead Pakistan's resistance against South Africa on the second day of the opening Test in Karachi.
Alam was holding fort on 63 as Pakistan reached 178 for six at tea, trailing South Africa's first innings total by 42 runs.
Playing his first Test at home, Alam was rock-solid as he added 94 with former skipper Azhar for the fifth wicket, leaving South Africa without a scalp in the first session.
The other batsman at the crease was Faheem Ashraf, who was yet to score.
South Africa's pace and spin attack toiled hard after the hosts resumed on a precarious 33 for four.
Pakistan added 71 in the first session before spinner Keshav Maharaj broke through by dismissing Azhar, caught behind by Quinton de Kock.
Azhar struck four boundaries in his 151-ball knock.
Wicketkeeper Mohammad Rizwan and Alam added another 55 for the sixth wicket before the former was caught at slip off paceman Lungi Ngidi.
It was a hard going for South Africa in the first session.
Kagiso Rabada, who took two wickets for just eight runs late Tuesday, looked threatening in his six-over spell, but Azhar and Alam batted cautiously to take Pakistan past 100.
Both batsmen survived scares, with left-arm spinner George Linde coming close to trapping Azhar leg-before on 29 -- the umpire's not-out decision upheld on review.
Alam was dropped on 35 by Dean Elgar, who failed to hold a sharp edge off spinner Keshav Maharaj in the slips.
The two-match series marks South Africa's first trip to Pakistan in 14 years, after a deadly 2009 attack on Sri Lanka's team halted visits by foreign sides.