South Africa was in a serious pinch after Pakistan routed the top order and left the Proteas reeling at 72-4, still trailing by 121 runs in the second innings on day three of an absorbing first test on Wednesday.
Alviro Petersen was out for 17, fellow opener and captain Graeme Smith for 32, Jacques Kallis for a duck on his 38th birthday, and Hashim Amla, the most prized wicket, was taken in the last over of the day for a mere 10.
AB de Villiers was 11 not out, and joined by nightwatchman Dale Steyn, who fended off the last five balls of the day surrounded by five fielders.
Pakistan smelled blood and a great chance at a first test win over South Africa since 2007.
"We are in a strong position and those four wickets have given us an advantage," said Khurram Manzoor, who stretched his maiden century by 15 runs in the morning before he was out for 146.
South Africa fast bowler Vernon Philander said they will be counting on de Villiers finding lasting resistance with JP Duminy and Faf du Plessis to try and avoid their first loss in 16 tests dating to December 2011.
"We need to be in the positive frame of mind, it's going to be hard work tomorrow," Philander said. "The Pakistani spinners have been good ... but we need to try and get some partnerships going."
Captain Misbah-ul-Haq's first test century in over two years helped the home team reach 442 and a formidable 193-run, first-innings lead. South Africa was bowled out for 249 in its first innings.
Misbah took advantage of the Proteas bowlers struggling to hit the right lines on a pitch devoid of grass for his 100 off 187 balls with eight fours.
His first hundred since an unbeaten 102 against West Indies in May 2011 in St. Kitts, built on the brilliant platform set by openers Shan Masood (75) and Manzoor, and extended by Asad Shafiq (54).
Manzoor's 146 off 266 balls with 15 fours became Pakistan's highest individual test knock against the Proteas, and spanned almost 6 1/2 hours. Azhar Mahmood held Pakistan's previous record with 136 in Johannesburg in 1998.
"I wanted to get the double (hundred), but made a mistake and got out," said Manzoor, who slashed at a wide Philander delivery and was caught at second slip. "My focus is always on scoring big whether I am playing a first-class match or an international match."
Misbah featured in two fruitful partnerships, adding 112 runs with Manzoor and 82 with Shafiq, dashing South Africa's hopes of keeping Pakistan's lead to less than 120 runs.
So enduring was South Africa's frustration that top-ranked test bowler Dale Steyn (3-88) took more than 23 overs for his first wicket when he had Misbah finally trapped leg before wicket. But the breakthrough came just two balls after the Pakistan captain reached three figures for the fourth time and raised his arms in joy to acknowledge the cheers of around 5,000 expat Pakistani supporters at Sheikh Zayed Stadium.
Misbah showed immense control, especially against spinners, as he did not hesitate to play reverse sweep before Steyn had him caught at the crease off a ball that came into him.
Shafiq also showed lots of composure in dominating their fifth-wicket stand as he elegantly cut, pulled and drove through the covers in his 105-ball knock with six fours. Shafiq perished soon after reaching his half century when he was smartly caught at short midwicket by Petersen off Duminy's offspin.
South Africa also got two more successes in the afternoon session when Philander (3-84) had Saeed Ajmal caught behind for 13 and Steyn's direct throw saw Zulfiqar Babar well short of his crease at the non-striker's end on 2. Steyn uprooted Adnan Akmal's stumps for 32 to end Pakistan's huge reply.
But Akmal featured in three of the four South Africa dismissals as he had Petersen and Amla caught behind off Mohammad Irfan and Babar respectively, and, despite fumbling with the ball off Saeed Ajmal's sharp turner, he managed to stump Smith. Kallis fell lbw to fast bowler Junaid Khan.