Stokes top-scored with 89 to push England to 311-8, before holding on to a brilliant catch at deep midwicket and taking 2-12 with the ball.
Archer made his presence felt even before he had taken a wicket with a bouncer that beat Hashim Amla for pace and crashed into the grille of the helmet, with the veteran retiring hurt on five.
Archer then struck in quick succession to remove Markram and Du Plessis to leave South Africa at 44 for two.
Markram edged to Joe Root at slip while Du Plessis top-edged a hook to long leg.
His exit saw Amla return with South Africa struggling at 167-6.
The game was all but up for South Africa when a back-pedalling and diving Stokes held a brilliant one-handed catch in the deep to dismiss Andile Phehlukwayo (24 off 25).
Amla's brave effort to rescue the innings ended on 13 when he was caught behind off Plunkett and Stokes finished the match when Imran Tahir (0) edged to Root.
England lost Jonny Bairstow (0) second ball before Roy and Root shared a 106-run stand before Morgan and Stokes added the same.
Du Plessis opted to field and took the unorthodox decision to open with Tahir. The leggie struck immediately when Bairstow was caught behind by De Kock for a golden duck.
Stokes saw his 79-ball knock end in the penultimate over when caught at third man. Lungi Ngidi finished with 3-66.