Pakistan, facing defeat in the second Test, were 132-4 at close on the third day in Dubai on Friday, needing another 286 runs to avoid an innings defeat. (Match scorecard)
Skipper Misbah-ul Haq was unbeaten on 42 and Asad Shafiq was 28 not out.
South Africa's victory bid was tarnished when they were docked five penalty runs for ball-tampering in the 31st over.
South Africa had made 517 in their first innings with Graeme Smith scoring 234 and AB de Villiers 164. South Africa compiled a big 418-run lead over Pakistan's paltry total of 99.
For Pakistan, off-spinner Saeed Ajmal finished with 5-161 and Mohammad Irfan took 3-102.
Pakistan lead the two-match series 1-0.