With 228 runs required and seven wickets in hand, Sarfaraz Ahmed and Co might have fathomed the improbable- chasing the target down.
Philander removed Shan Masood for two runs and then had Azhar Ali out first ball to bring to nine the number of wickets in a dramatic final session on what was supposed to be a docile wicket at the Wanderers.
Middle-order batsmen Babar Azam and Asad Shafiq were unbeaten on 17 and 48 runs respectively.
It was his first century against Pakistan and also his first on his initial home ground and made sure that he will finish the series as South Africa's leading runs scorer.
Having reached his fourth Test hundred, De Kock was eventually dismissed for 129 as South Africa were bowled out for 303 midway through the afternoon session.
Jayme Closs case: Suspect saw parents as 'barrier' to kidnapping
For the past couple of months the community of Barron and beyond has been praying for a safe return of 13-year-old Jayme Closs. The double-storey house had a trampoline in the backyard and a disused boat covered in tarps in the yard.
One of the remaining batsmen will clearly have to score the century that has eluded them in the series to date if Pakistan are to win the match. They came together on Saturday when their side was in shambles at 93 for five, at which stage their lead was a modest 170.
Oliver opened the door in the third over of the day when he had the unsafe Babar Azam (21) hopping with the vicious bouncer that the dynamic stroke-maker could only fend behind to Quinton de Kock. De Kock was involved in all three wickets to fall to complete a memorable day.
He now has 433 wickets which puts him in joint eighth place with Sri Lanka's Rangana Herath, who has just retired, and England's Stuart Broad.
The record is held by Charlie Llewellyn, a spinner who claimed 25 wickets in 1902 against Australia.
SOUTH AFRICA (1st Innings) 262 (A.K. Markram 90, T.B.M. du Bruyn 49, H.M. Amla 41, Zubayr Hamza 41; Faheem Ashraf 3-57). Faheem Ashraf and Shadab Khan were the pick of the Pakistan bowlers in the second innings as they bagged three wickets apiece.