South Africa's fast bowlers dismissed Pakistan's top four batsmen as they pushed for victory on the third day of the first Test at the Wanderers Stadium on Sunday.
Pakistan were 104 for four at tea after being set to make an improbable 480 to win.
Each of South Africa's four fast bowlers claimed a wicket. The batsmen out were Mohammad Hafeez, Nasir Jamshed, Azhar Ali and Younis Khan.
AB de Villiers hurried to a century before South Africa declared on 275 for three, leaving Pakistan with an hour's batting before lunch.
De Villiers needed only 33 balls to move from his overnight 63 to 103 not out. He and Hashim Amla added 68 in nine overs before the declaration, which came immediately after De Villiers punched Umar Gul to the cover boundary to reach his 15th Test century off 117 balls. He hit 11 boundaries.
Amla was unbeaten on 74 off 114 balls with seven fours. The pair put on an unbeaten 176 for the fourth wicket, easily the best partnership of the match.
After being routed for their all-time low total of 49 in the first innings, Pakistan made a more confident start to the second innings and Hafeez was somewhat unfortunate to fall to a diving catch by AB de Villiers when he glanced Vernon Philander to leg.
Jamshed and Azhar put on 57 for the second wicket but tight bowling by Dale Steyn and Vernon Philander after lunch slowed the scoring rate down.
The left-handed Jamshed, playing in his first Test match, looked solid before he was out for 46 when he pulled Steyn tamely to midwicket.
Azhar followed three overs later for 18. Having been subjected to some hostile short-pitched bowling from Steyn he was trapped in front of his stumps when he played across a full delivery from Jacques Kallis.
Morne Morkel took his first wicket of the match when Younis was caught behind for 15, nibbling at and then attempting to withdraw his bat from a fast delivery outside his off stump.