England need eight wickets for victory on the final day of the second Test in Cape Town after being frustrated by South Africa’s top order.
Dom Sibley made 133 not out – his maiden Test ton – and Ben Stokes hit 72 as England declared on 391-8 to set the Proteas a Test record 438 to win.
Joe Denly removed opener Dean Elgar for 34 and Zubayr Hamza fell for 18 to James Anderson in the penultimate over.
But Pieter Malan remained unbeaten on 63 as South Africa closed on 126-2.
Anderson’s late strike provided England a welcome boost on a Newlands pitch not offering as much variable bounce as England would have hoped for by now.
They will still have to work hard and stay patient to secure victory, but have time and runs to play with, given the hosts require a further 312 to win.
Resuming on 85, Sibley made careful progress towards his century, reaching the mark off 269 balls in the 14th over of the day with a firm sweep off Keshav Maharaj for four.
After removing his helmet to acknowledge the crowd and embrace Stokes, the Warwickshire batsman settled straight back into his task, padding away, leaving and waiting for the bad ball.
By stark contrast, Stokes – dropped on 38 by Quinton de Kock at full stretch as he ran towards square leg – had already smashed his way to a 34-ball half-century by the time Sibley reached three figures.
It was stunning onslaught by the all-rounder, hitting Maharaj down the ground, reverse-sweeping medium pacer Dwaine Pretorius and crashing anything over-pitched through the covers before he finally holed out at long-on.
Stokes’ thrilling knock took the game completely away from South Africa at a stirring pace and was made possible by Sibley’s patient accumulation, providing a glimpse of how England may have been able to bat with a more reliable top order in recent years.
Jos Buttler hit two sixes in a brisk 23 and Sibley also showed more invention with a few reverse sweeps before captain Joe Root finally called his side in 20 minutes after lunch.
Anderson and Stuart Broad bowled a decent opening spell but Malan and Elgar left well and kept rotating the strike to repel England’s premier duo.
Both also used their feet well when off-spinner Dom Bess was introduced early and Root had to turn to the part-time leg-spin of Denly to break an opening stand of 71.
Targeting the rough outside Elgar’s off stump, Denly drew the left-hander forward and induced a very thin edge through to Buttler, with a small spike on UltraEdge meaning the decision was not overturned after a bemused Elgar called for a review.
England remained patient but were matched by South Africa, with impressive debutant Malan steadily bringing up his maiden Test half-century off 146 balls.
Stokes was saved until the 40th over and tested both batsmen with quick, short-pitched bowling, drawing a few false shots from Hamza, but without success.
Anderson was duly given one last burst and England’s all-time highest Test wicket-taker delivered, finding reverse swing to move the ball away from Hamza, who nicked to Buttler and perhaps ease any nerves.
Nightwatchman Maharaj survived Sam Curran’s final over and will hope to survive for as long as possible on Tuesday before South Africa’s key batsman and captain Faf du Plessis starts his innings.