Quinton de Kock's fourth Test century put South Africa in a strong position to complete a 3-0 Test series sweep over Pakistan, who showed late resilience on day three in their battle to avoid defeat.

Wicketkeeper-batsman De Kock equalled his Test-best score of 129 as the Proteas posted a second-innings total of 303, leaving the tourists a daunting target of 381.

Hashim Amla played his part with a measured 71 off 144 deliveries before being caught behind by wicketkeeper Sarfraz Ahmed, whose involvement in 10 dismissals in a match set a new record for Pakistan.

Dale Steyn struck twice in close proximity to dismiss openers Imam-ul-Haq (35) and Shan Masood (37) and move into the top-10 list of all-time Test wicket takers on 433.

But Azhar Ali (15) was the only other wicket to fall and, while they require another 228, Asad Shafiq (48 not out) and Babar Azam's (17no) partnership led the tourists to 153-3 at the close to retain an outside chance.

After scoring at a run-a-ball rate to make 34 overnight, De Kock was much more measured early on Sunday against a testing Pakistan bowling unit.

Amla's steady work ended when he gloved a Hasan Ali delivery, while Vernon Philander (14) hit three crisp boundaries before being trapped lbw by Mohammad Amir.

De Kock did manage four boundaries before lunch but Mohammad Abbas was smacked for three more as the pace of scoring picked up in the second session.

A few jitters followed as the personal landmark approached before De Kock finally drilled one to the fence to bring up his century. He eventually holed out off Shadab Khan, having hit a solitary six and 18 fours.

Kagiso Rabada (21 off 62) had been a reliable partner but South Africa's innings folded in a hurry, their final three wickets going down for one run.

Steyn made his mark to break Pakistan's opening stand when Imam got a thin edge behind to wicketkeeper De Kock.

A fuming Masood soon followed when technology was needed on a South Africa review for a catch behind, but there was less doubt about Azhar's wicket as he gloved behind a rising delivery from Olivier.

Yet Shafiq, who hit Olivier for three fours in one over to take Pakistan past 100, and Babar rattled along in an unbeaten 49-run stand, giving the visitors a glimmer of hope heading into Monday's play.