Temba Bavuma led South Africa's resurgence against West Indies after a slow start to finish day three of the second Test with a lead of 356 with three wickets remaining.
A strong opening session for the visitors provided hope with the deficit just 138 at lunch, with South Africa already four wickets down at the Wanderers.
However, captain Bavuma turned the tide with a valiant display with the bat to put his side in cruise control and finished the day unbeaten on 171.
Just four runs shy of 3,000 in his Test career, Bavuma could start day four with two landmarks if he adds another 29 on Saturday.
Kyle Mayers struck twice early as West Indies took momentum, with Kemar Roach then landing the big wicket of Aiden Markram (18) as he forced an edge to Joshua Da Silva.
Bavuma led South Africa's recovery, putting on 37 with Ryan Rickelton (10) for the fourth wicket, but Raymon Reifer removed Rickelton in the last over before lunch to end the session on a high.
The Proteas responded in the second session, despite losing Heinrich Klaasen for 14, with Bavuma and Wiaan Mulder (42) adding a partnership of 103.
Mulder eventually fell to Alzarri Joseph after pulling a short ball to Tagenarine Chanderpaul, before Simon Harmer (19) was trapped lbw by Jason Holder.
South Africa will resume on 287-7 on day four assuming they do not declare overnight, with Bavuma presumably eager to complete his first ever Test double century.
Unstoppable Bavuma
When the South Africa captain walked out to bat, his side were 8-2 and had already lost Markram, but Bavuma repaired the innings and established a commanding lead with his second Test ton.
His tally leaves him sat on 2,996 runs in his Test career, with a landmark on the cards if South Africa do not declare overnight.
Mayers' strong start
Dismissing Dean Elgar (5) and Tony de Zorzi (1) inside the opening eight overs, Mayers looked to have put West Indies on course to clawing their way back into the Test.
He only conceded 25 runs from his 13 overs, but the tourists had no answer to Bavuma's stunning display.