England lost its top three batsmen in its second innings inside 10 overs as Alex Hales, Alastair Cook and Nick Compton all departed without reaching double figures.
Joe Root and James Taylor, both on 19 not out, held South Africa at bay until stumps on the fourth day. England was still 330 runs short.
Fast bowler Kagiso Rabada had 2-15 to go with his seven wickets in the first innings to lead South Africa's push for a consolation win. England already clinched the series in the third test, taking a 2-0 lead with this last match to play.
South Africa wins toss and bats 1st in 2nd test vs. England