South Africa remain on top against Pakistan in the third and final Test after a breathless 13-wicket day two in Johannesburg.
Duanne Olivier's third five-wicket haul of the series saw South Africa skittle Pakistan for 185 to take a 77-run advantage on first innings but the hosts slumped to 45-4 before Hashim Amla (42no) guided them to 135-5, a lead of 212.
The Proteas were wasteful early on in the field, spilling four catches and fumbling a run-out opportunity in a wicketless first hour, only to then strike three times before lunch at Wanderers.
Pakistan captain Sarfraz Ahmed (50 from 40 balls) rallied after the interval, dominating an enterprising sixth-wicket stand of 78 from 61 balls with Babar Azam (49) before Olivier mopped up the innings.
However, South Africa's top order malfunctioned, including stand-in skipper Dean Elgar (5) and the out-of-form Theunis de Bruyn (7), with the home side grateful to Amla's partnerships of 48 and 42 with Temba Bavuma (23) and Quinton de Kock (34no) respectively for steadying matters.
Elgar - leading South Africa in the absence of the suspended Faf du Plessis - and Bavuma had been guilty of a drop apiece in the morning, while wicketkeeper De Kock spilled two in addition to missing a stumping chance.
Pakistan moved from 17-2 to 53-2 before Olivier picked up two wickets in four balls after drinks, nightwatchman Mohammad Abbas (11) snicking behind and Asad Shafiq (0) doing likewise as he failed to deal with a bouncer.
A climbing Vernon Philander ball also undid Imam-ul-Haq (33), who was finally dismissed having been grassed on 12 and 33 and also survived a run-out chance when Rabada failed to hit the stumps.
Babar was rattled on the chest by Olivier early on but consistently found the fence before lunch after counter-attacking against Olivier and Steyn - the latter having returned to the field after traipsing off holding his surgically-repaired shoulder.
Sarfraz - also put down by Elgar at slip when he had just eight - took over the boundary-scoring mantle upon the resumption, reaching his 18th Test fifty from 38 deliveries, before clipping Rabada behind two balls later.
Olivier then removed Babar and Faheem Ashraf (0) from successive balls, before completing his five-for when Mohammad Amir (10) lobbed a short ball to short leg as Pakistan slumped from 169-5.
South Africa were soon struggling, with Elgar falling to Amir on review and Aiden Markam (21) edging Abbas, before De Bruyn and Zubayr Hamza (0) were out to Faheem Ashraf in the space of three balls.
But there was no shifting Amla, who successfully overturned an lbw dismissal on 19 after inside-edging a delivery from Hasan Ali, bowling in sunglasses having had midges fly into his eyes a short while earlier.
Pakistan did remove Bavuma - the batsman clipping a leg break from Shadab Khan into Sarfraz's gloves - yet that only brought De Kock to the crease, with the left-hander swelling South Africa's advantage with six boundaries.
Watch day three of the third Test between South Africa and Pakistan, in Johannesburg, live from from 7.55am on Sunday on Sky Sports Cricket (channel 404).