The match was evenly poised after the opening day on Friday with South Africa bowled out for 253 and Pakistan 0-6 at stumps after facing two overs, but then the Proteas bowlers showed why they continue to dominate world cricket in the first session of Day 2.
Dale Steyn led the way taking 6-8 from 8.1 overs as South Africa ripped through the tourists and bowled them out for their lowest ever Test score of 49.
South African captain Graeme Smith decided not to enforce the follow-on and by the end of Day 2 the Proteas had advanced to 3-207 in their second innings with an overall lead of 411.
Hashim Amla and AB de Villiers were the not out batsmen overnight and that's how it stayed on Sunday morning with de Villiers finishing up on 103 not out and Amla not out on 74 before Smith declared the innings closed on 3-275.
That left South Africa 479 in front and with more than two and-a-half days to bowl out Pakistan out for a second time after it took just 29.1 overs in the first innings.
Pakistan required a world record 480 to win the Test and the run chase started off in disastrous fashion with Mohammad Hafeez out for two in the fourth over.
Debutant Nasir Jamshed and No. 3 Azhar Ali then combined for 57 for the second wicket before Jamshed fell for 46 when caught by Robin Peterson off Steyn.
Pakistan was then 3-70 when Ali was out for 18 when trapped LBW off Jacques Kallis.
The experienced Younis Khan didn’t long either when he was out for 15 when caught behind off Morne Morkel with the score 4-82.
That proved to be South Africa's last breakthrough for the day, though, with captain Misbah and Shafiq showing tremendous fight and grit.
By the end of the third day's play, Misbah had moved along to 44 from 138 balls with Shafiq unbeaten on 53 from 144 balls.
While Misbah and Shafiq put on a tremendous unbeaten partnership of 101 to close the day's play, it didn’t come without some drama and luck along the way.
Shafiq appeared to be out for 40 when Smith took a sharp catch at first slip with the score on 4-155, but umpire Billy Bowden went upstairs and it showed that Vernon Philander had overstepped the front foot line.
That brought Shafiq back to the crease and the very next over his captain offered a simple chance to Peterson at point, but he put it down off the bowling of Jacques Kallis with Misbah on 31.
After those two scares on 4-155 and 4-156, Misbah and Shafiq settled back down and took things safely to stumps at 4-183 but with two full days to go and South Africa due the second new ball early on Monday morning, the pair have a lot of work to do to see Pakistan avoid a heavy defeat.