Pakistan were struggling at 64-3 in response to South Africa's first innings total of 615 at stumps on day two of the second Test in Cape Town.
After Ryan Rickelton's 259-run knock led the hosts to the huge score, Kagiso Rabada (2-9) and Marco Jansen (1-14) struck for South Africa with the ball to deal early blows to Pakistan in their reply.
Babar Azam will resume the third day on 31 runs for the tourists, who are without opener Saim Ayub, who has been ruled out of the Test with a broken ankle.
Earlier in the day, Kyle Verreynne had partnered Rickelton to smash a century off 147 balls before Jansen (62) and Keshav Maharaj (40) saw the Proteas to 615.
The hosts added 299 runs to their overnight total of 316-4, amassing them at a rate of almost five runs an over before making a solid start with the ball in hand.
Shan Masood (2) fell inside the first over to Rabada before Kamran Ghulam (12) and Saud Shakeel (0) shortly followed to put South Africa in control.
Pakistan will resume the third day still 551 runs behind and effectively with only six wickets in hand in the absence of Ayub.
Day 2 comes to a close with Pakistan on 64-3 and they trail by 551 runs.
— Proteas Men (@ProteasMenCSA) January 4, 2025
Kagiso Rabada got the breakthrough in the first over and struck on either side of a Marco Jansen wicket. We pick it up tomorrow at 10:30.#WozaNawe #BePartOfIt #SAvPAK pic.twitter.com/B17ya9ZGjn
Data Debrief: Rickelton's record innings
Rickelton's 259 from 343 balls is South Africa's joint seventh-highest score in Test cricket, matching former captain Graeme Smith's innings against England in 2003.
Only Hashim Amla (311*), AB de Villiers (278*), Smith (277), Darryl Cullinan (275*), Gary Kirsten (275) and Graeme Pollock (274) have scored more in a single innings for South Africa.
It is also the highest individual score for a first-time opener in Test cricket, with only Sri Lanka's Brendon Kuruppu (201*), Smith (200) and New Zealand's Devon Conway (200) having registered double tons in their maiden innings as a Test opener before.