Image courtesy of: ESPNcricinfo
Duanne Olivier secured his second five-for in the match as Pakistan were bundled out for 190 to set South Africa 149 to win on the second day in Centurion.
Starting off the day on 127/5, South Africa lost nightwatchman Dale Steyn early on as he was caught behind off the bowling of Mohammad Amir for 23.
Temba Bavuma managed to score 53, which came off 87 balls and included nine boundaries, before he was caught behind off the bowling of Shaheen Shah Afridi.
Keshav Maharaj was the next to go, but Quinton de Kock and Kagiso Rabada added 31 runs to the score before Rabada was dismissed by Afridi for 19.
South Africa were eventually bowled out for 223, which gave them a 42-run lead, when De Kock was caught by Fakhar Zaman at cover off the bowling of Amir for 45.
Amir and Afridi picked up four wickets apiece, while Hasan Ali chipped in with two.
Trailing by 42 runs, Pakistan made a solid start to their second innings as Imam-ul-Haq and Zaman forged a 44-run partnership before Zaman was caught by Rabada at long leg off the bowling of Olivier for 12.
Imam and Shan Masood added 57 runs to the score, during which Imam registered his fifty, before he was clean bowled by Olivier for 57, which came off 96 balls and included eight boundaries and a six.
Olivier struck again in his next over as Azhar Ali was caught by Rabada at short midwicket for a duck.
Steyn joined the party after Azhar’s dismissal as he had Asad Shafiq caught behind for six runs.
Rabada then took out Babar Azam, captain Sarfraz Ahmed and Amir in quick succession before Yasir Shah was caught behind off the bowling of Olivier for a golden duck.
Masood went on to score a 120-ball 65, which included seven boundaries and a six, before he was removed by Steyn.
Pakistan ended up being bowled out for 190, which set South Africa 149 to win, when Afridi was caught by Aiden Markram at short leg off the bowling of Olivier for four runs.
Olivier was the most successful bowler with five wickets, while Rabada took three and Steyn claimed two.
South Africa will begin their chase of 149 on Friday at 10:00 local time or 08:00 GMT