Alastair Cook was eight not out and Alex Hales unbeaten on five to give England a lead of 18 runs going into the final day.
Earlier, South Africa had declared on 627 for seven after a memorable unbeaten 102 by Temba Bavuma and 201 from Hashim Amla to leave the match looking set to end in a draw.
Cook, who has scored only 42 runs in four innings during
the series, was caught down the leg side by wicketkeeper Quinton de Kock off Kagiso Rabada and Hales fell to an outstanding catch by Chris Morris at third slip, diving low to his right, off Morne Morkel.
More From This Section
Root had an escape on 17 when he edged a catch to AB de Villiers at second slip off Morkel, only for a television review to show it was a no-ball.
Compton dug in and played a solid defensive innings in making 15 off 60 balls. It came as a surprise when he went on the drive against a full delivery from off-spinner Dane Piedt and hit a catch to Faf du Plessis at a short mid-on position.
But he went for a big hit against Piedt and was caught by Morkel on the midwicket boundary for 26.
Taylor followed in Piedt's next over, gloving a catch to Temba Bavuma at short leg after making 27. At 116 for six, less than midway through the day, England were in trouble when Bairstow and Ali came together.