It gave them the three-match series 2-0.
England set a daunting target of 346 for victory, were dismissed for 294 on Monday s final day with seamer Vernon Philander, who finished the innings with two wickets in two balls, taking five for 30.
South Africa, who won the first Test at The Oval by an innings and 12 runs before the second match of the series at Headingley was drawn, only needed to avoid defeat at Lord s to replace England at the top of the International Cricket Council s world Test rankings.
Both sides collapsed to 54 for four in their first innings.
England s Jonathan Bairstow made 95 after replacing Kevin Pietersen when the South Africa-born batsman was dropped, despite making 149 at Headingley, for sending "provocative texts", believed to contain criticisms of captain Andrew Strauss, to Proteas players.
The tourists, having conceded a narrow first innings lead, made 351 all out in their second innings with Hashim Amla scoring 121 to follow his South Africa record 311 not out at The Oval.
England fast bowler Steven Finn, on his Middle+++ home ground, took four wickets in each innings for a match haul of eight for 149.
History was against England as the most they had ever made in the fourth innings to win a Test was the 332 for seven they posted against Australia at Melbourne back in 1928/29.
Seam bowler Philander reduced England to 34 for three. But another fifty from Bairstow and one from Jonathan Trott, kept the Proteas at bay.
Matt Prior led a late victory charge with a dashing 73 before he was caught off Philander by South Africa captain Graeme Smith at first slip.
Next ball Finn was taken by second slip Jacques Kallis and England s time at the top was over.
Defeat meant England had lost a home Test campaign for the first time in eight series since South Africa s 2-1 success in 2008.
And it gave them a record of just three wins in 11 Tests, with six defeats and two draws, since replacing India at the top of the ICC standings last year.
South Africa 309 (JP Duminy 61, V Philander 61; S Finn 4-75, J Anderson 3-76) and 351 (H Amla 121; S Finn 4-74)
England 315 (J Bairstow 95, I Bell 58; M Morkel 4-80, D Steyn 4-94) and 294 (M Prior 73, J Trott 63, J Bairstow 54; V Philander 5-30)
Result: South Africa won by 51 runs
Series: South Africa win three-match series 2-0