AB de Villiers has hit a century to help South Africa post a first-innings total of 409 against Pakistan in Centurion.
Hashim Amla was the pick of the hosts' openers, hitting 92 from just 128 deliveries before De Villiers and Vernon Philander built a century partnership.
De Villiers (121) was one of Rahat Ali's six victims soon after Philander fell to the bowling of Younis Khan.
Lunch was called after Pakistan had reached 9-0 from their first five overs with Mohammad Hafeez (1*) and Imran Farhat (8*) at the crease.
South Africa have already won the three-Test series by claiming the first two Tests.