Ready to add to cart? The three-day Great Online Sale has begun, with discounts of up to 95 per cent at your fingertips this weekend
Set to make a daunting 381 to win, Pakistan were 153 for three at the close, needing another 228 runs.
De Kock's 129 and a double strike by Dale Steyn kept South Africa on course but Asad Shafiq and Babar Azam batted brightly towards the close to give Pakistan some hope.
"It's going to be quite tough," said De Kock. "The pitch has flattened out. It's definitely got better, surprisingly. I thought with the new ball it would do a lot more than it did."
Imam-ul-Haq and Shan Masood got Pakistan off to their best start of the series, putting on 67 for the first wicket.
They were largely untroubled by South Africa's all-pace attack until Steyn changed ends and dismissed both openers in quick succession.
When Azhar Ali fell cheaply to Duanne Olivier for the fourth time in the series, gloving a bouncer to wicketkeeper De Kock, a South African win seemed certain.
But Shafiq raced to 48 not out off 47 balls, while Azam looked comfortable in making 17 not out.
Realistically, though, the odds favour the home team with only captain Sarfraz Ahmed, a couple of all-rounders and the tail to come.
"We'll have a chat about it tonight. They have a couple of decent batsmen in the mix so we'll have to box cleverly tomorrow," said De Kock.
Pakistan bowling coach Azhar Mahmood said the remaining Pakistan batsmen would need to follow the example of De Kock and Hashim Amla, who enabled South Africa to recover from a precarious 93 for five.
While Amla patiently compiled 71 off 144 balls, the left-handed De Kock played fluently as the pair put on 102 for the sixth wicket. De Kock also shared an eighth wicket stand of 79 with Kagiso Rabada.
"Our plan was to get them out so we would be chasing 270-280 but credit goes to De Kock and Amla," said Mahmood, who said he remained confident.
"We've done it before. Two guys are batting really well. If they can bat for a long period of time we've got a really good chance."
Mahmood said at least one of the remaining batsmen would have to get a century.
"If these guys do the same thing that Amla and De Kock did we've got a chance," he said.
Mahmood agreed with De Kock that the pitch was playing easier but he cautioned that there was some uneven bounce towards the close on Sunday.
De Kock reached his fifty off 49 balls and his fourth Test century off 121 deliveries.
He was finally caught in the deep, trying for a second successive six off leg-spinner Shadab Khan, after facing 138 balls and hitting 18 fours and a six.
Shadab finished with three for 41 while medium-pacer Faheem Ashraf took three for 42.
Sarfraz set a record for a Pakistan wicketkeeper by taking five catches in each innings.
His total of ten dismissals in the match was one better than the record previously shared by Rashid Latif and Kamran Akmal.
Pakistan only made one total over 200 in their first five innings in the series and had not batted for longer than 70.4 overs.
Steyn's two wickets took his total in Tests to 433, bringing him level with Sri Lanka's Rangana Herath and Stuart Broad of England in joint eighth place on the all-time Test wicket-takers list.Hsts on top
South Africa first innings, 262
Pakistan first innings, 185
South Africa second innings
(overnight 135-5)
D. Elgar c S Ahmed b M Amir 5
A. Markram c S Ahmed b M Abbas 21
H. Amla c S Ahmed b H Ali 71
T. de Bruyn c A Shafiq b F Ashraf 7
Z Hamza lbw b F Ashraf 0
T. Bavuma c S Ahmed b S Khan 23
Q. de Kock c H Ali b S Khan 129
V. Philander lbw b M Amir 14
K. Rabada c S Khan b F Ashraf 21
D. Steyn not out 0
D. Olivier c S Ahmed b S Khan 1
Extras (b2, lb6, nb1, w1) 11
Total (80.3 overs) 303
Fall: 1-24, 2-29, 3-45, 4-45, 5-93, 6-195, 7-223, 8-302, 9-302
Bowling: M Amir 20-2-56-2, M Abbas 18-3-73-1 (1w), Hasan Ali 17-1-83-1, F Ashraf 14-3-42-3 (2w), S Khan 11.3-0-41-3
Pakistan second innings
Imam c De Kock b Steyn 35
S Masood c De Kock b Steyn 37
A Ali c De Kock b Olivier 15
A Shafiq not out 48
B Azam not out 17
Extras (lb1) 1
Total (3 wkts, 40 overs) 153
Fall: 1-67, 2-74, 3-104
Bowling: Steyn 12-1-37-2, Philander 10-3-28-0, Olivier 8-2-41-1, Rabada 10-1-46-0
Match situation: Pakistan need 228 runs to win with seven wickets remaining
Toss: South Africa
Umpires: Sundaram Ravi (IND), Joel Wilson (WIN)
TV umpire: Bruce Oxenford (AUS)
Match referee: David Boon (AUS)
Ready to add to cart? The three-day Great Online Sale has begun, with discounts of up to 95 per cent at your fingertips this weekend
In Hiroshima, the city devastated by the first nuclear bomb, the biopic's Academy Awards success met a mixed reaction
The Bollywood actor hosted the inaugural Hope Gala in London attended by prominent global personalities
More than 50 people are coming in to get the shot every day, doctors say
The nol cards can be used not only for public transport but also to make essential purchases at participating retail outlets in the emirate
The Italian company stands as the first Italian real estate brokerage group operating in the UAE
'The Australian batter also thinks 'there's no one better in India to have behind the stumps'
Policybazaar.ae unveils heartfelt short film advocating the need for term insurance