Stokes was 98 not out when tea interrupted his charge at Emirates Old Trafford, within touching distance of his 12th Test ton having powered his side to 308 for five.
England had been four runs behind when he came together with Foakes in the morning session but the pair had turned that into a handsome lead of 157 during a wicketless afternoon.
Stokes hit three sixes and six fours but a strike-rate of 63.22 told a better story about the balance he was able to strike between power and poise.
Crawley had ground out just 17 runs from 77 balls but there was an early sign that things would be different in his first scoring shot, a thick edge that disappeared through the slip cordon for four.
He also found himself squared up by Anrich Nortje, with a loopy leading edge somehow failing to go to hand at cover.
Nortje, not the for the first time this series, was hitting his straps and asking searching questions at venomous pace. It was a heady mix and enough to account for both overnight batters before the deficit had been cleared.
Bairstow was first to go for 49, nicking a reverse-swinging delivery to slip to end a stand worth 91. Crawley marginally outlasted him, and picked off a couple of boundary balls from Kagiso Rabada, but was undone for 38 when Nortje forced him to defend on off stump and found just enough shape to flick the edge.
South Africa led by 17 when Stokes emerged and four when Foakes joined him, but the duo settled neatly into the job of building an English advantage. Stokes saw out the remainder of Nortje’s opening burst and then rewarded himself by slog-sweeping his first ball from Simon Harmer for six.
He had 16 when a dashed single left him wincing in pain, his troublesome left knee once again causing him discomfort, but after a visit from the physio he was soon punching Lungi Ngidi down the ground with a wonderful check drive.
Foakes proved a sound foil as England progressed confidently, successfully overturning an lbw decision on 28 before clubbing a no-ball for four just before lunch to take the total past 100 runs for the session.
Perhaps surprisingly, Nortje was held back at the restart in favour of spin at both ends. Keshav Maharaj almost bowled a reverse-sweeping Stokes second ball but otherwise the game began drifting away from the tourists.
Stokes injected some adrenaline by smashing Harmer for six to bring up the first half-century of the match. Nortje returned for a three-over spell but could not recreate his previous menace, conceding 13 without much discomfort.
Stokes was increasingly emboldened, stepping away to swat Ngidi over extra-cover before launching Maharaj over long-off for six more. Foakes quietly ticked past 50 at the other end before South Africa unwrapped a new ball to try and lift their fortunes.
Stokes greeted its arrival by easing into the 90s with a flick off his pads, then hammered Ngidi to cover. Aiden Markram made a fine effort to pull of a wonder catch but had to make do with a plucky parry.
South Africa sent an lbw appeal upstairs when Nortje struck Stokes on 96 just before tea but the ball was missing leg.