England, set a mammoth 474 runs for victory, collapsed to 133 all out in their second innings 40 minutes before tea on the fourth day.
No England batsman made a fifty in an innings where former captain Alastair Cook's 42 was the top score.
England, who resumed on one without loss, lost four wickets before lunch and a further six before tea.
Man-of-the-match Vernon Philander led South Africa's attack on Monday with three wickets for 24 runs in 10 overs, while left-arm spinner Keshav Maharaj took three for 42 in 12.
Duanne Olivier ended the match by taking two wickets in two balls to dismiss tailenders Mark Wood and James Anderson.
Returning South Africa captain Faf du Plessis, who did not play in the Proteas' 211-run defeat in the first Test at Lord's following the birth of his first child, made the bold decision to bat first after winning the toss and was rewarded by a total of 335 featuring several fifties including Hashim Amla's 78.
England could only manage 205 in reply, with Joe Root making 78 in his second Test as captain.
Amla (87), Dean Elgar (80) and du Plessis (63) piled on the runs in South Africa's second innings 343 for nine declared.
It meant England needed to surpass the West Indies' record fourth innings score to win a Test of 418 for seven against Australia at St John's in 2003 if they were to achieve an improbable victory.
But they never looked like getting close as South Africa won a Test at Trent Bridge for the first time since 1965 despite being without suspended fast bowler Kagiso Rabada, banned from this match for swearing at Ben Stokes at Lord's.
The series continues at The Oval on July 27.
South Africa 335 (H Amla 78, Q de Kock 68, V Philander 54; J Anderson 5-72, S Broad 3-64) and 343-9 dec (H Amla 87, D Elgar 80, F du Plessis 63; M Ali 4-78) v England 205 (J Root 78; K Maharaj 3-21, C Morris 3-38) and 133 (V Philander 3-24, K Maharaj 3-42)
Result: South Africa won by 340 runs
Man-of-the-match: Vernon Philander (RSA)
Series: Four-match series level at 1-1
First Published: July 17, 2017, 8:29 PM IST