Duanne Olivier and Hashim Amla helped South Africa remain on top against Pakistan as momentum swung back and forth on an eventful day two of the third Test.
The Proteas endured a dismal start in the field after Pakistan resumed on 17-2, with four drops and a missed run out coming inside the opening hour in Johannesburg.
Paceman Olivier (5-51), who had match figures of 11-96 in the first Test, finally made the breakthrough, but Babar Azam (49 off 55) and Sarfraz Ahmed (50 off 40) lifted Pakistan before the tourists lost their last five wickets for just 16 runs.
South Africa looked in trouble at 45-5 inside 15 overs, but Amla (42 not out) maintained his composure to get his team to stumps without further loss, meaning they hold a lead of 212 runs.
STUMPS:— Cricket South Africa (@OfficialCSA) January 12, 2019
The Proteas end day 2 with a 212 run lead on 135/5 after 37 overs.
A fine knock by @amlahash (42*) in the third session who was partnered by @QuinnyDeKock69 (34*)
The @Bullring buzz continues on Day 3. Play gets underway at 10:00#ProteaFire #SAvPAK pic.twitter.com/qTROz2ybVG
The Proteas wasted a number of chances early on, with nightwatchman Mohammad Abbas (11) inexplicably dropped by Temba Bavuma at gully off Vernon Philander (3-43).
Dale Steyn – who later appeared to be struggling with his troublesome right shoulder – saw Imam-ul-Haq (43) and Abbas put down by Dean Elgar, after a touch off Theunis de Bruyn, and Quinton de Kock respectively.
South Africa's wicketkeeper was then unable to gather an outside edge from Imam, who was oblivious to Abbas attempting to snatch a run. The latter had to turn back but Kagiso Rabada failed to punish him, missing the stumps with his throw.
De Bruyn finally held on to an opportunity as Abba fell to Olivier, who removed Asad Shafiq for a three-ball duck in the same over.
Babar turned up the tempo in a fine knock that included 10 fours – half of which came from two Steyn overs – but Imam was unable to make it through to lunch unscathed.
Sarfraz shared a 78-run partnership for the sixth wicket until the Pakistan captain was taken at first slip by Amla, Babar then falling shy of his half-century to Olivier just four balls later.
Olivier was unable to complete a hat-trick after dismissing Faheem Ashraf (0) but Pakistan were skittled for 185 when Rabada (2-41) had Shadab Khan caught at gully for five.
Things are moving quickly in Johannesburg.— ICC (@ICC) January 12, 2019
Pakistan collapse from 169/5 to 185 all out. Duanne Olivier the star of the show yet again, taking 5/51.
South Africa lead by 77 runs. #SAvPAK LIVE https://t.co/jCOIZUOF6T pic.twitter.com/czZIUTB3uH
Pakistan were unsuccessful with a review for lbw against Aiden Markram (21) but Sarfraz got it right in the next over, his challenge showing Elgar had edged Mohammad Amir (1-28) through to the wicketkeeper.
Markram went to Abbas in the first over after tea and, after another poor challenge from Sarfraz failed to get rid of Amla, Faheem (2-19) claimed the scalps of De Bruyn (7) and Zubayr Hamza (0) in the space of three balls.
The home team appeared in real troubl at that stage, yet Amla responded with back-to-back fours off Hasan Ali (0-27), who at one stage was forced to stop in his run-up due to a swarm of insects that bugged Pakistan in the field in the final session.
De Kock - who reached the close unbeaten on 34 - helped keep the score ticking over and the pair made it to the close with an unbeaten 42-run union that Pakistan will need to break early on day three.
|Record-breaking evening ´one of those nights´ for Warriors star Thompson|
|Hazard still interested in Real Madrid but won´t rule out Chelsea stay|
|Collins moves past Pavlyuchenkova, into Australian Open semis|
|Kohli makes history with ICC awards sweep|
|Thompson sets NBA record with 10 straight made three-pointers to open game|
|76ers hand Rockets largest loss of season, Harden scores 37 points|
|Tsitsipas overcomes Bautista Agut to continue Aus Open run|
|Barcelona move a ´dream come true´ for Boateng|
|Rams coach McVay on Gurley: I´ve got to get him more opportunities|
|Butler´s sprained wrist not expected to keep him out ´long term´|
|Saints owner Benson will ´aggressively pursue changes in NFL policies´|
|Levante to take Copa case to CAS|
|It can happen – Allegri plays down Ronaldo penalty miss|
|Mavericks´ Doncic becomes second-youngest player to record triple-double|
|Yankees send Sonny Gray to Reds|
|Ashley Cole reunited with Frank Lampard at Derby County|
|Arnold ready to mix things up in 2019 Asian Cup quarter-finals|
|Arum: Joshua desperately needs to fight in the United States|
|South Korea v Bahrain: Bento optimistic of continuing unblemished campaign|
|Bolton Wanderers 0 West Brom 2: Baggies bounce up to third after tennis ball protest|
|Confident Moeen ready to shine for England in the Caribbean|
|Juventus 3 Chievo 0: Allegri´s men cruise despite Ronaldo penalty save|
|Boateng completes shock Barcelona switch|
|United Arab Emirates 3 Kyrgyzstan 2 (after extra time): Khalil penalty sets up Socceroos showdown|
|West Indies add Drakes to new-look coaching team|
|Barcelona is a huge opportunity – Boateng confirms shock move is close|
|Donnarumma wishes Higuain luck ahead of expected Chelsea switch|
|Qatar v Iraq: Katanec anticipating ´huge challenge´ in last 16|
|Nuno hit with FA misconduct charge for pitch celebration|
|Furious Carreno Busta and Zverev bow out, Djokovic marches on|
|#NotMartinFromWakefield – Siewert shows viral sensation the door|
|Djokovic feeling the strain after late-night Medvedev battle|
|Henderson sidelined again ahead of Six Nations|
|Australia 0 Uzbekistan 0 (aet, 4-2 on penalties): Ryan heroics see holders hobble onwards|
|Halep exit leaves four-way fight to be crowned number one at Australian Open|
|Super Bowl-bound Rams set for London return, Chiefs to face Chargers in Mexico|
|Huddersfield appoint Siewert as Wagner´s replacement|
|Genoa 0 AC Milan 2: Borini and Suso step up with Higuain left out|
|McTominay signs new Manchester United contract|
|Pizzi to stand down after Saudi Arabia elimination|
|Boateng closing in on shock Barcelona switch - reports|
|Catalans to defend Challenge Cup after resolving RFL dispute|
|Djokovic wears down Medvedev to reach last eight|
|Mouratoglou: I knew ´loyal´ Serena would not fire me after US Open turmoil|
|Barcelona B defender Wague accuses Ejea fans of racist abuse|
|I felt like I had been hit by a train - Halep upbeat despite losing Serena battle|
|Arsenal confirm Mislintat departure|
|Icardi will renew, 100 per cent - Wanda Nara offers latest Inter assurance|
|Japan 1 Saudi Arabia 0: Four-time winners send Pizzi´s men out|
|A souvlaki maybe named after him, a growing fan base – Tsitsipas creating Melbourne buzz|
|Barca winger Dembele out for 15 days|
|Strikers blown away by Hurricanes in Adelaide|
|Ireland lose Beirne for England and Scotland clashes|
|´Innate fighter´ Serena says character key to beating Halep|
|Hudson-Odoi ´an outstanding talent´ - Bayern great Ballack hails Chelsea youngster|
|Scotland call up four as hand injury forces Watson out|
|Serena comes through major Halep battle to reach last eight|
|Better than Rafa? Camacho cameo leaves Klopp unconvinced by transfer options|
|England job ´a privileged position´, says Southgate|
|Emery has confidence in Arsenal outcast Ozil|
|Zverev destroys racquet in Aus Open meltdown|
|From Villarreal to Aus Open quarters – Bautista Agut breaks major duck|
|Brees: I plan on being here next year and making another run at it|
|´Unf******-believable bro!´ - Brady stunned after reaching third straight Super Bowl|
|New England find answers, penalty costs Kansas City – three takeaways from Patriots´ win over Chiefs|
|Donald Trump congratulates Brady and Super Bowl-bound Patriots|
|Rose helps Timberwolves down Suns|
|Brady leads Patriots into third straight Super Bowl|
|Osaka overcomes Sevastova to reach quarters|
|Chelsea remain behind Sarri – David Luiz|