Duanne Olivier took six for 37 as the hosts subjected Pakistan to an onslaught of aggressive, short-pitched bowling.
South Africa struggled in reply, reaching 127 for five at the close, with left-armers Mohammad Amir and Shaheen Shah Afridi both taking two wickets.
Teenager Afridi struck with successive deliveries, dismissing Dean Elgar and captain Faf du Plessis as South Africa lost three wickets without scoring a run to sink to 43 for four.
Theunis de Bruyn (29) and Temba Bavuma (38 not out) seemed to be regaining the ascendancy for South Africa as they added 69 for the fifth wicket but De Bruyn was caught behind off Amir late in the day to leave the match evenly poised.
— Consistently hostile —
Olivier, effectively South Africa’s fifth-choice fast bowler, gained his sixth Test cap following injuries to Vernon Philander and Lungi Ngidi. He was consistently hostile, especially in a seven-over spell after lunch when he ripped through Pakistan’s middle order, taking three for 17.
Olivier stole the limelight for South Africa on a day when Dale Steyn became South Africa’s leading all-time wicket-taker.
Steyn took the second wicket of the match, having Fakhar Zaman caught at second slip, to claim the South African record with 422 Test scalps but had no further success. He was punished for 40 runs in four overs in his third spell of the day as Babar Azam went on the attack while batting with the tail. Azam hit 10 of his 15 fours off Steyn, who finished with one for 66.
Azam made a defiant 71 off 79 balls on a pitch already showing signs of uneven bounce. Hasan Ali (21) supported Azam in a ninth wicket stand of 67, easily the best of the innings.
Olivier’s first victim was Shan Masood, who was playing in place of Haris Sohail, who suffered a knee injury during the pre-match warm-up. Masood looked competent as he and Azhar Ali put on 37 for the third wicket before a lifting delivery deflected off his thigh pad onto the stumps. Olivier followed up by trapping Asad Shafiq leg before wicket before he took the wickets of Azhar Ali, captain Sarfraz Ahmed and Mohammad Amir after the break.
South Africa lost Aiden Markram early, leg before to Hasan Ali, but Elgar and Hashim saw off some tight bowling by Hasan and Mohammad Amir. The advantage seemed to be shifting when Elgar hit three boundaries off successive balls from Hasan.
Amir returned to the attack after a short break and had Amla caught at gully for eight, the latest in a string of low scores by the veteran batsman.
Tall left-armer Afridi, 18, playing in his second Test, followed up in the next over when Elgar was caught at first slip, trying to withdraw his bat, and Du Plessis was greeted by a ball which reared off a good length and he was caught at gully. The South African captain looked suspiciously at the pitch before departing.