Image courtesy of: ESPNcricinfo
Quinton de Kock stole the spotlight with his knock of 129 on the third day in Johannesburg, but Pakistan fought hard after being set 381 to win by South Africa.
Starting off the day on 135/5, De Kock and Hashim Amla converted their 42-run partnership into a 102-run stand before Amla was caught behind off the bowling of Hasan Ali for 71, which came off 144 balls and included 14 boundaries.
Vernon Philander fell shortly after, but De Kock and Kagiso Rabada steadied things with a 79-run partnership, during which De Kock brought up his hundred, before he was dismissed by Shadab Khan for 129, which came off 138 deliveries and included 18 boundaries and a six.
Rabada went on to score 21 before he was caught by Shadab at extra cover off the bowling of Faheem Ashraf.
South Africa ended up being bowled out for 303, which set Pakistan 381 to win, when Duanne Olivier was caught behind off the bowling of Shadab for one run.
Shadab and Faheem picked up three wickets apiece, while Mohammad Amir took two, and Hasan and Mohammad Abbas chipped in with one wicket each.
Chasing 381 to win, Pakistan got off to a great start as Imam-ul-Haq and Shan Masood amassed a 67-run partnership before Imam was caught behind off the bowling of Dale Steyn for 35.
Masood managed to score 37 before he suffered the same fate as Imam.
Azhar Ali only mustered 15 runs before he was caught behind off the bowling of Olivier.
With Pakistan having lost three quick wickets, Asad Shafiq and Babar Azam came to the rescue as they forged an unbeaten 49-run stand before stumps was called.
Shafiq finished on 48, which came off 47 balls and included eight boundaries, while Azam remained undefeated on 17, which came off 21 deliveries and included four boundaries.
Steyn was the most successful bowler with two wickets, while Olivier claimed one.
Pakistan ended day three on 153/3 and will continue batting on Monday at 10:00 local time or 08:00 GMT.