England reached 162 for four at tea, 151 runs behind South Africa's first innings total of 313.
Root who is 60 not out and Stokes who is unbeaten on 38 smashed a 50 run partnership in just 35 balls after England bad been reduced to 91 for four.
Kagiso Rabada took two for 31 as South Africa's four-man pace attack battered the English top order with fiery spells.
England got off to a bad start when Rabada removed Alex Hales for one.
South African debutant Hardus Viljoen took a wicket with his first ball having England Captain Alastair Cook caught down the leg side by wicketkeeper Dane Vilas for 18.
Earlier, the hosts were bowled out for 313 on the second morning of the third Test against England in Johannesburg on Friday.
Resuming on their overnight score of 267 for 7, South Africa could add just 46 runs before their innings came to an end.
Stokes was the leading wicket taker with three scalps while Stuart Broad, Steven Finn took two wickets each.
Wicketkeeper Jonny Bairstow took six catches but missed a chance to equal the world record of seven when he dropped last batsman Morne Morkel.
England lead the four match series 1-0.
D. Elgar c Bairstow b Ali 46
S. van Zyl c Bairstow b Stokes 21
H. Amla c Bairstow b Finn 40
A. de Villiers c Bairstow b Stokes 36
F. du Plessis c Hales b Finn 16
T. Bavuma run out (sub - Woakes) 23
D. Vilas c Ali b Broad 26
C. Morris c Bairstow b Broad 28
K. Rabada c Bairstow b Anderson 24
H. Viljoen not out 20
M. Morkel c Cook b Stokes 12
Total (all out; 99.3 overs) 313
Bowling: Anderson 25.2-5-60-1, Broad 22-5-82-2 (1w), Finn 18-4-50-2 (2nb), Ali 16-4-50-1, Stokes 18.1-1-53-3
A. Cook c Vilas b Viljoen 18
A. Hales c De Villiers b Rabada 1
N. Compton c Elgar b Rabada 26
J. Root not out 60
J. Taylor c Bavuma b Morkel 7
B. Stokes not out 38
Total (4 wkts, 39 overs) 162