Ryan Rickelton and captain Temba Bavuma led South Africa out of trouble, bringing the home side to 316/4 at the end of Day 1 in the second Test at Newlands.
At the close of play, South Africa had added 132 runs for the loss of just one wicket, thanks to the 235-run partnership between Rickelton and Bavuma.
This stand was broken in the 77th over when Salman Ali Agha got Bavuma caught behind. Bavuma scored 106 from 179 balls, including nine fours and two sixes.
After Bavuma’s dismissal, Rickelton was joined by David Bedingham, and together they added nine runs to the total before stumps.
At stumps, Rickelton was unbeaten on 176 off 232 deliveries, including 21 fours and one six, while Bedingham was 4 not out.
For Pakistan, Agha took two wickets, while Khurram Shahzad and Mohammad Abbas chipped in with one each.
The home side dominated the second session, adding 112 runs without losing a wicket as Rickelton and Bavuma frustrated Pakistan’s bowlers.
At tea, Rickelton was unbeaten on 106 from 149 balls, with 14 boundaries, while Bavuma was on 51, with six fours.
South Africa opted to bat first after winning the toss. Their opening pair of in-form Aiden Markram and Rickelton put together a 61-run partnership.
Markram made 17 off 40 balls before being caught behind off Khurram Shahzad. Wiaan Mulder, returning to the side after recovering from a thumb injury, failed to make an impact, dismissed by Abbas for five.
Pakistan’s third breakthrough came through Salman Agha, who dismissed Tristan Stubbs for a duck.
By stumps, Rickelton and Bavuma had led South Africa to 316/4.
South Africa leads the two-match series 1-0, having won the first match by two wickets.