South Africa face a huge battle to avoid defeat in the third Test against England after the hosts declared with a mammoth lead of 491 at The Oval before claiming four wickets in the final session on day four.
Debutant Tom Westley (59 from 141 balls), skipper Joe Root (50 from 94) and wicketkeeper-batsman Jonny Bairstow (63 from 58) made half-centuries of contrasting urgency as England gradually accelerated from an overnight score of 74-1 to 313-8 declared.
Needing to bat out four sessions to salvage a draw, the tourists lost Heino Kuhn (11) to Stuart Broad in the sixth over of their second innings, two balls after Dean Elgar had been dropped at third slip by Keaton Jennings off James Anderson.
Three wickets in the space of seven balls significantly strengthened England's hold on proceedings. Toby Roland-Jones, the star performer with the ball in the Proteas' first dig, again picked up the prized scalp of Hashim Amla (5) before Ben Stokes accounted for Quinton de Kock (5) and Faf du Plessis (0) with successive deliveries - the latter lbw padding up for the second time in the match.
Elgar doggedly overcame a number of uncomfortable moments, mainly against the hugely impressive Stokes (2-29), to remain unbeaten on 72 and received able support from Temba Bavuma (16 not out) in a restorative stand of 65 that lifted South Africa to 117-4 at the close.
However, the hosts nevertheless remain firm favourites to move 2-1 up in the series ahead of the final Test at Old Trafford.
The under-pressure Jennings fell two short of a half-century in Sunday's morning session, which began with England 252 ahead for the loss of just one second-innings wicket, when he was caught at gully off a lifter from Kagiso Rabada.
With Morne Morkel again finding excellent rhythm, Westley was largely becalmed prior to lunch but moved to 50 with a glorious clip through midwicket for four.
England's new number three was eventually stumped off Keshav Maharaj (3-50), who also had the typically busy Root caught in the deep as England sought to raise their run-rate ahead of a declaration.
After Dawid Malan had added just 10 to his first-innings score of one on debut, Stokes (31) and Bairstow provided the required impetus, the latter playing an array of stylish strokes.
Roland-Jones joined the party with two sixes off the part-time spin of Elgar, before Bairstow's dismissal at the hands of Maharaj convinced Root to declare.
England soon had South Africa on the rack with the ball, Roland-Jones following up Broad's initial breakthrough by inducing an edge from Amla to second slip as the batsman looked to leave.
When Stokes yorked De Kock and found appreciable movement to send Du Plessis back for a golden duck, the Proteas were in a miserable position at 52-4.
Bavuma saw off Stokes' hat-trick ball, though, and neither he nor Elgar could be shifted in the 21 overs that followed.