South Africa suffered a few scares before knocking off the 149 runs required and sealing a six-wicket victory over Pakistan in the first Test at Centurion thanks to half-centuries from Hashim Amla and Dean Elgar.
Pakistan boosted their hopes of an unlikely win on day three when Hasan Ali pinned Proteas opener Aiden Markram lbw for a duck in the second over.
Drama unfolded with South Africa's score on 16 when Amla was dropped by Fakhar Zaman off Hasan and then TV umpire Joel Wilson decided Azhar Ali had not caught Elgar cleanly at slip after Shaheen Afridi found the edge.
Pakistan's players were stunned at Wilson overturning the soft signal of out - and then frustrated as Amla (63no) and Elgar (50) braved some excellent bowling to put on 119 for the second wicket.
Amla's fifty was his 40th in Tests with Elgar - who received a nasty blow on the forearm from a Mohammad Amir delivery in the first session - notching his 13th before he clipped Shan Masood behind a ball later.
Amla also passed 1,000 Test runs against Pakistan as he guided his team home alongside Temba Bavuma (13no), following the exits of Theunis de Bruyn (10) and Faf du Plessis (0) to Yasir Shah and Shaheen respectively.
Du Plessis' dismissal created a cricketing quirk, marking the first time two captains have bagged a pair in the same Test, with his opposite number Sarfraz Ahmed also failing to score at SuperSport Park.
South Africa will now be looking to wrap up a series win with a game to spare when they welcome Pakistan to Cape Town for the second Test, live on Sky Sports Cricket from 8.25am on Thursday, January 3.
Proteas quick Duanne Oliver caused the most damage in a bowler-dominated first Test, bagging match figures of 11-96 having come into the side for the injured Vernon Philander - a man Du Plessis expects to be fit for Cape Town.
Dale Steyn claimed three wickets in the game, with the first of those seeing him overtake Shaun Pollock as South Africa's most prolific Test bowler.
Watch day one of the second Test between South Africa and Pakistan, live on Sky Sports Cricket from 8.25am on Thursday, January 3.