Stokes slammed 258 and Bairstow made 150 not out before England declared on 629 for six. The pair shared a world Test record sixth wicket partnership of 399.
A bad day for South Africa got worse when Stiaan van Zyl was run out in the third over of their reply. South Africa were 24 for one at tea.
The left-handed Stokes thrashed 30 fours and 11 sixes in a 197-ball innings. He reached his double century off 163 balls, the second fastest in Tests behind Nathan Astle's 153-ball effort for New Zealand against England at Christchurch in 2001/02.
With a declaration imminent, Stokes pounded the next delivery into the stands for another six before, in trying to hit a third, he skied the ball to AB de Villiers at mid-on. De Villiers dropped it but ran out Stokes with a direct hit to the bowler's end.
- Relentless assault -
======================
The South African bowlers had no answer to a relentless assault, which started with 45 runs scored off the first four overs of the day, bowled by Morne Morkel and Chris Morris.
place fielders on the boundary on both sides of the wicket but Stokes continued to power the ball past them. By the end of the first hour, which yielded 103 runs off 13 overs, there were five men on the boundary.
The two hours before lunch yielded 196 runs despite South Africa bowling only 25 overs. Stokes made 130 of them off 74 balls, a new record for individual runs scored before lunch on any day of a Test. He beat the 123 by Leslie Ames for England against South Africa at The Oval in 1935.
South Africa's malaise was summed up when Morkel dropped Bairstow on 138. The batsman drove Morris to long-off and the ball went through Morkel's hands.
De Villiers, another senior player in a largely inexperienced team, followed suit when he dropped Stokes, although De Villiers made amends by picking up the ball and running out Stokes.
He was sent back by Dean Elgar and Nick Compton's throw to wicketkeeper Bairstow beat him comfortably.
