South Africa made an early breakthrough after setting Pakistan a target of 480 to win on the third day of the first Test at the Wanderers Stadium on Sunday.
Pakistan were 47 for one at lunch, Mohammad Hafeez caught behind off Vernon Philander for two in the fourth over.
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 27 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 Philander to leg.
Conditions seemed easier for batting than in the first innings and Dale Steyn, who took six for eight in Pakistan's collapse, was not able to make the ball swing as much as on Saturday, although he bowled with pace and accuracy, conceding just eight runs in five overs.
Nasir Jamshed, playing in his first Test, was unbeaten on 39. He gave a half-chance to Dean Elgar at short leg off Morne Morkel when he had 26.