England were 317 for five at the close, with the left-handed Stokes on 74 not out.
An injury-depleted South African bowling attack, spearheaded by Kagiso Rabada, kept England in check for much of a hot, cloudless day on a batsman-friendly pitch.
Rabada, 20, playing in his first home Test, took three for 74. The match seemed evenly poised when Joe Root was dismissed for 50 by new cap Chris Morris. But Stokes and Jonny Bairstow (39 not out) put on an unbeaten 94 for the sixth wicket.
Stokes was particularly aggressive against the second new ball, hitting the first two deliveries from Morris for fours to post a 70-ball half-century. He hit two more fours and a single in the same over. By the close he had faced 93 balls and hit 11 fours and a six.
Alex Hales and Root hit half-centuries, while Nick Compton made 45 after England won the toss and made first use of a pitch with good bounce but minimal sideways movement.
Hales, playing in his second Test match, hit 60 -- his maiden Test half-century -- and shared stands of 55 with opening partner Alastair Cook and 74 for the second wicket with Compton.
Cook made 27 before edging Rabada low to third slip where Morris dived far to his left and held the ball centimetres above the ground. Compton was out in the last over before tea when he pulled a ball from Rabada and was well caught by a diving Temba Bavuma at midwicket.
Rabada made it two wickets in two balls when he dismissed James Taylor with the first ball after tea but Root and Stokes put on 56 for the fifth wicket before Morris claimed his first wicket in Test cricket when Root edged an attempted cut to wicketkeeper Quinton de Kock.
Fast bowlers Rabada and Morris were playing in place of Dale Steyn and Kyle Abbott, who suffered shoulder and hamstring injuries respectively during South Africa's 241-run defeat in the first Test in Durban.
Rabada and off-spinner Dane Piedt were both playing in their fourth Test match, leaving Morkel, in his 69th Test, as the only experienced member of the South African bowling attack.
Both Rabada and Morris built up good pace, with Rabada clocked at 150kmh shortly before dismissing Cook.
In a third change for South Africa, De Kock replaced out-of-form batsman JP Duminy. De Kock kept wicket, with AB de Villiers playing as a specialist batsman.
England fast bowler James Anderson, who missed the first Test because of a calf strain, was passed fit and replaced Chris Woakes.
England, 1st innings: A Cook c Morris b Rabada 27 A Hales c De Villiers b Morkel 60 N Compton c Bavuma b Rabada 45 J Root c De Kock b Morris 50 J Taylor c De Kock b Rabada 0 B Stokes not out 74 J Bairstow not out 39
Extras: (b-10, lb-1, nb-4, w-7) 22; Total: (For 5 wkts; 87 overs) 317
Fall of wicket: 1-55, 2-129, 3-167, 4-167, 5-223
Bowling: Morkel 18-3-51-1, Morris 22-3-99-1, Rabada 19-2-74-3, Piedt 21-5-63-0, Van Zyl 5-0-12-0, Elgar 2-0-7-0.