Abu Dhabi - South Africa increased their lead over Pakistan in a bid to enforce a result in the second Test played at Abu Dhabi Stadium on Tuesday.
The Proteas lost opener Alviro Petersen in the last over before tea on the fourth day, caught by Younis Khan off Abdul Rehman for 35 with the total on 81. Hashim Amla was unbeaten on 46 at the break.
South Africa have an overall lead of 231 after dismissing Pakistan for 434 in their first innings, but they are running out of time to enforce a result in this match and the series which is tied at 0-0.
The first Test ended in a draw in Dubai last week.
Pakistan were in danger of following-on but their tail-enders led by Abdul Rehman, who hit a career-best 60, avoided that danger and kept their hopes of salvaging another draw alive.
South Africa started on a positive note when they dismissed Pakistan skipper Misbah-ul-Haq for 77 off the first delivery of the day, trapped leg-before by paceman Dale Steyn who finished with 4-98.
Rehman then became Pakistan's saviour, adding 36 for the eighth wicket with Umar Gul, who scored 21, to bring Pakistan closer.
When left-arm spinner Paul Harris (3-98) trapped Gul leg-before, Pakistan needed 32 to avoid the humiliation of being asked to bat again, but Rehman hit Harris for a six and then took a single to avert the danger.
The Rehman-Ahmed stand of 59 for the ninth wicket ended when Morne Morkel had debutant Ahmed out soon after lunch for 30.
Rehman hit eight boundaries and a six during his fighting, 139-ball knock, improving on his best score of 25 not out made against the same opponents in Lahore three years ago.
He was the last man out, trapped leg-before by Johan Botha.
South Africa - Graeme Smith (capt), Alviro Petersen, Jacques
Kallis, Hashim Amla, AB de Villiers, Ashwell Prince, Mark Boucher (wk),
Johan Botha, Paul Harris, Dale Steyn, Morne Morkel.
Pakistan - Taufeeq Umar, Mohammad Hafeez, Azhar Ali, Asad Shafiq, Younis Khan, Misbah-ul-Haq (capt), Adnan Akmal (wk), Abdur Rehman, Umar Gul, Mohammad Sami, Tanvir Ahmed.