Fawad Alam made his third Test century as Pakistan took the upper hand on a frustrating day two for South Africa in Karachi.
Pakistan resumed on Wednesday in deep trouble on 33-4 in reply to the Proteas' 220 all out but recovered to 308-8 at stumps with an 88-run lead at the National Stadium.
Fawad made a superb 109, while Azhar Ali (51) and Faheem Ashraf (64) also played big hands as Babar Azam's side turned the tide following such a dramatic opening day of the two-match series.
Left-hander Fawad was dropped on 35 and 92 by Dean Elgar and Quinton de Kock respectively before bringing up his hundred with a six off spinner Keshav Maharaj.
The Proteas failed to take a wicket in the first session, which ended with Pakistan on 104-4, but former captain Azhar was caught behind off Maharaj (2-71) to end a stand of 94 with Fawad after digging in for a 33rd half-century in the longest format.
Mohammad Rizwan (33) fell to Lungi Ngidi in the final over before tea to leave Pakistan 176-6, but Fawad and Faheem took Pakistan into the lead with a partnership of 102.
Ngidi (2-55) ended Fawad's brilliant 245-ball knock and Faheem played on to an Anrich Nortje (2-84) yorker, but it was very much Pakistan's day, with Maharaj denied a third wicket when he bowled Hasan Ali but over-stepped.
THAT moment!January 27, 2021
Fawad making up for lost time
Middle-order batsman Fawad has made up for lost time after being recalled to face England last August almost 11 years after his previous Test appearance.
The left-hander was rattled on the helmet by Kagiso Rabada and had some deserved fortune as he played superbly to put Pakistan in a strong position.
Fawad has gone on to reach three figures on all three occasions he has made a half-century. He struck two sixes and found the rope nine times before he was taken by Temba Bavuma at short midwicket to become Ngidi's second victim.
Rabada made to wait for landmark
Proteas paceman Rabada took two wickets in a devastating new-ball burst late on day one, but remains one shy of 200 Test scalps.
He bowled probing lines without reward and was economical, missing out on reaching the landmark when captain De Kock dropped Fawad in the 90s.