South Africa seamer Kyle Abbott marked his Test debut with figures of 7-29 as Pakistan were made to follow-on at Centurion.
Pakistan were bowled out for 156 in reply to South Africa's 409 and then slipped to 14-1 in their second innings at stumps on day two of the final Test, still 239 runs behind.
South Africa, who need a win to complete a 3-0 series sweep, advanced their first innings from 334-6 to 409 all out at the start of the day.
AB de Villiers, on 98 overnight, completed his 16th Test century before being eighth out for 121, one of left-arm paceman Rahat Ali's 6-127 haul.
Openers Mohammad Hafeez and Imran Farhat put on 46 either side of lunch as Pakistan made a promising start in reply.
But Farhat's exit, lbw to Vernon Philander for 30, sparked a collapse as South Africa's seam attack ran riot.
Abbott, a 25-year-old who was the leading wicket taker in South Africa's first-class competition this season and only playing in this game due to Jacques Kallis' calf strain, claimed Hafeez as his maiden Test scalp.
Philander (2-30) bowled Azhar Ali (6) and Dale Steyn (1-25) chipped in with the wicket of Asad Shafiq (6) but otherwise it was the Abbott show as he ran through the lower order.
Younus Khan was last out, lbw to Abbott, for 33, the top score of an innings lasting 46.4 overs.
Abbott's figures are the second best by a South African on debut, only bettered by Lance Klusener - his bowling coach at the Dolphins franchise - who claimed 8-64 against India in Kolkata in 1996.
South Africa captain Graeme Smith enforced the follow-on and Steyn promptly bowled Hafeez for a duck with the first ball of Pakistan's second innings.
Ali and Younus managed to negotiate the final nine overs of a miserable day for Pakistan without further loss.