LONDON - South Africa were set a target of 331 to win the first Test at Lord's after dismissing England for 233 in their second innings on Sunday's fourth day.
Jonny Bairstow, dropped on seven, revived England's innings before he was last man out for 51.
England lost seven wickets in the morning session to be 182 for eight at lunch having resumed on 119 for one.
Left-arm spinner Keshav Maharaj took four for 85 in 32.1 overs, with the new ball duo of Kagiso Rabada (three for 50) Morne Morkel (three for 64) sharing the remaining six wickets between them in the first of this four-Test series.
Only once have a side made more than 300 to win in the fourth innings of a Test at Lord's, with West Indies, on the back of Gordon Greenidge's brilliant unbeaten double century, posting 344 for one to defeat England by nine wickets in 1984.