Kagiso Rabada headlined South Africa's tremendous fightback in the last hour as Pakistan's top-order lost the plot in the first Test in Karachi on Tuesday.
Pakistan reached stumps on day one at 33/4, having dominated proceedings for a majority of the day by bundling out the visitors for 220.
A total of 14 wickets fell as the National Stadium pitch sprang to life right from the get-go. South Africa had raced to 108/2 soon after lunch before a spate of soft dismissals left them filled with regret at how the innings panned out.
They were still able to surpass their lowest total in Pakistan - 214 at Faisalabad in 1997 - by a meagre six runs.
Pakistan's spin duo of the experienced Yasir Shah and debutant Nauman Ali were at the fore of the disciplined effort while pacer Shaheen Afridi also chipped in with two wickets.
Having gained the momentum by the end of the first innings, South Africa paid back the hosts with interest with Rabada striking early to remove Abid Ali.
The speedster then got rid of debutant Imran Butt by a sharply rising delivery that was caught by the substitute fielder at leg-gully. The two wickets he added to his tally has helped him to 199 scalps in 44 games with Pakistan's first innings still underway.
Babar Azam fell victim to straighter delivery from Keshav Maharaj, failing to make a mark with the bat on his Test captaincy debut.
Nightwatchman Shaheen was then clean bowled by a rapid delivery from Anrich Nortje without troubling the scorers.
The two unbeaten batsmen for Pakistan were Azhar Ali and Fawad Alam, both having trudged to five runs with Pakistan trailing a mammoth 187 runs.
Opening batsman Dean Elgar was the top run-getter for South Africa with the 16th half-century of his career. He was supported by lower-order contributors George Linde and Rabada to help the tourists surmount the 200-run mark.
Elgar expressed confidence in his team's ability to restrict Pakistan's batting, though he admitted South Africa's batters were unsuccessful owing to some reckless shot selection and ordinary running between the wickets.
The gritty left-handed batsman hit nine fours in his impressive knock before he edged Nauman to Babar at slip.
Elgar and former Proteas skipper Faf du Plessis had completed a fine recovery job with a 45-run stand for the third wicket after Aiden Markram and Rassie van der Dussen got out in the morning session.
Later, Temba Bavuma and Linde desperately afforded stability to the innings with a 43-run partnership for the sixth wicket but they could not progress further when Bavuma was run-out by a wonderful piece of fielding from Hasan Ali.