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.
|Emery ´not positive´ over Bellerin injury|
|Harden scores 48 points as Rockets rally past Lakers in OT|
|Pacquiao wants Mayweather rematch after beating Broner|
|Sharapova unimpressed with questions after Melbourne exit|
|Nadal outclasses Berdych en route to quarters|
|Collins trounces 2016 Aus Open champion Kerber|
|Sanchez: Man United thriving thanks to Solskjaer|
|Sharapova crashes out of Australian Open|
|Devils´ Palmieri replaces Hall on NHL All-Star roster|
|Tuchel stunned by PSG´s nine-goal thrashing of Guingamp|
|Modric wants to extend Real Madrid stay|
|Marotta: Icardi will re-sign, Godin wants Inter|
|´F*** no!´ - Westbrook on if he´s cool with Embiid|
|Mickelson shoots 66 to stay ahead at Desert Classic|
|Real Madrid? You never know what the future holds - PSG´s Mbappe|
|Inter lacked quality in disappointing Sassuolo draw - Spalletti|
|Walton has one goal for Lakers-Rockets matchup: Keep Harden under 50 points|
|CAF Champions League Review: Simba learn Vita lesson as Sundowns find form|
|Bayliss relishing pressure of World Cup and Ashes to finish England reign|
|Guardiola keen to keep City rhythm and challenge on four fronts|
|Fifita backs Johnson to inspire the Sharks|
|For Real Madrid, nothing is impossible - Solari refuses to give up in title race|
|Inter 0 Sassuolo 0: Spalletti´s side labour at sparse San Siro|
|Marshawn Lynch will continue playing ´if it works out´|
|Simeone excited by improving Atleti|
|Jones ´cautiously optimistic´ over Farrell ahead of Ireland clash|
|Sarri questions Chelsea motivation after Arsenal surrender|
|Emery urges Arsenal to find balance after downing Chelsea|
|Koscielny hails Arsenal fighting spirit in Chelsea win|
|Pellegrini: It was not a good idea for Arnautovic to play|
|Iran v Oman: We´re not satisfied yet, says Al Mahaijri|
|Carbery sends Munster through and ends Exeter´s lingering Champions Cup hopes|
|Dyche defiant despite offside call|
|Hasenhuttl rates Everton win as Southampton´s best|
|Benitez looking up the table after Schar inspires win over Cardiff|
|RB Leipzig 0 Borussia Dortmund 1: Witsel restores six-point cushion|
|Swansea City 1 Sheffield United 0: McBurnie punishes wasteful Blades|
|Cardiff sign Sala from Nantes for club-record fee|
|Arsenal 2 Chelsea 0: Lacazette and Koscielny fire Gunners to rousing derby win|
|Huesca 0 Atletico Madrid 3: Dominant Atleti keep pressure on Barca|
|Rashford arguably league´s best striker with Kane out - Solskjaer|
|Hafeez plays steady hand as Pakistan punish Proteas´ patient approach|
|Klopp: Exceptional Salah would have scored even more up front!|
|Suspected ´serious´ Verratti injury leaves Tuchel with mixed emotions|
|We needed to rediscover our best form - Ramos pleased for Real Madrid fans|
|City bought Guardiola four full-backs! - Mourinho aims dig at Man Utd transfer policy|
|Valverde ´not frustrated´ amid De Jong & Vela links|
|Championship Review: Leaders Leeds beaten at Stoke as Villa end Hull run|
|Bournemouth rode their luck, admits Howe|
|Barca boss Valverde calls for clarity on RFEF rules|
|Bears rack up 107 points in routing Enisei en route to quarter-finals|
|Paris Saint-Germain 9 Guingamp 0: Verratti injured for rampant champions|
|Solskjaer: I´ll remember managing United for the rest of my life|
|Palace win a ´massive relief´ for Liverpool boss Klopp|
|Salah fourth fastest to 50 goals in Premier League history|
|Real Madrid 2 Sevilla 0: Solari´s side take over third spot|
|Watford 0 Burnley 0: Wood denied winner by contentious call|
|Liverpool 4 Crystal Palace 3: Salah reaches 50 thanks to Speroni shocker|
|Newcastle United 3 Cardiff City 0: Schar double moves hosts out of bottom three|
|Southampton 2 Everton 1: In-form Saints steer clear of trouble|
|Bournemouth 2 West Ham 0: Wilson and King sink Pellegrini´s men|
|Manchester United 2 Brighton and Hove Albion 1: Record-breaking win for Solskjaer|
|Pelicans star Anthony Davis out for one to two weeks with sprained finger|
|Verratti hobbles off for PSG against Guingamp|
|Brook ponders next move after missing out on Khan|
|Mick Schumacher: The Ferrari academy graduates who made it to F1|
|Thailand v China: Lippi aims to overcome War Elephants and reach last eight|
|I deserved red card, says Wolves boss Nuno|
|Mick Schumacher joins Ferrari Driver Academy|
|Jared Goff not worried about Superdome noise: ´When it´s loud, we love it´|