The Proteas, set 331 to win, collapsed to 119 all out inside 37 overs.
The result meant Joe Root, who made 190 in the hosts' first innings 458, enjoyed a resounding victory in his first Test as England captain, with his side now 1-0 up in this four-match series.
Off-spinner Ali, the man-of-the-match, finished with Test-best figures of six for 53 in 15 overs -- including a burst of five for 20 in 25 balls -- on a pitch offering sharp turn.
No South Africa batsman made more in the innings than Temba Bavuma's 21.
England vs South Africa, Day 4: As It Happened
The day started well for South Africa as England, who resumed on 119 for one in their second innings, lost seven wickets before lunch in a dramatic collapse.
But in the midst of the clatter of wickets, Vernon Philander dropped a routine catch at long-off when Jonny Bairstow, mistiming a drive off left-arm spinner Keshav Maharaj, was on seven.
Bairstow punished the Proteas by making 51 before he was last man out in a total of 233, stumped by opposing wicket-keeper Quinton de Kock off Maharaj.
The scale of South Africa's task could be seen from the fact that only once, when the West Indies posted 344 for one against England in 1984, had a side made more than 300 in the fourth innings to win a Lord's Test.
Bairstow, the son of late former England wicket-keeper David Bairstow, has often been criticised for the quality of his glovework.
But he held a brilliant one-handed catch, diving low down the legside, to give England their first wicket Sunday when Test debutant Heino Kuhn (one) glanced James Anderson.
South Africa's 12 for one became 12 for two when stand-in skipper Dean Elgar (two) drilled a return catch to Ali.
JP Duminy then hammered a pull off Wood and Ali held a good catch at midwicket to leave South Africa 25 for three on the stroke of tea.
If the Proteas were to now pull off an improbable win they needed a major innings from Hashim Amla.
But the star batsman fell for his interval score of 11 when, beaten on the outside edged by an excellent delivery from left-arm spinner Liam Dawson he was lbw.
There was a brief pause before Ali transformed South Africa's 61 for four into 82 for eight.
De Kock (18) and Bavuma were both bowled aiming across the line, with Theunis de Bruyn, Keshav Maharaj and Kagiso Rabada also falling to Worcestershire's Ali.
Maharaj's exit gave Ali a 10th wicket of a match where he had earlier completed the all-rounder's Test double of 2,000 runs and 100 wickets and made 87 in England's first innings.
Dawson ended the match when Morne Morkel holed out to South Africa-born Keaton Jennings in the deep.
Former England captain Alastair Cook was 59 not out overnight and Gary Ballance unbeaten on 34.
The pair found runs hard to come by against a South Africa attack now back to full strength with Philander returning having been unable to bowl Saturday having been hit on the hand while batting.
When Rabada had Ben Stokes plumb lbw he jokingly put a finger to his lips -- a reference to his ban from Friday's second Test at Trent Bridge for swearing at the all-rounder after dismissing him in England's first innings.
But it was England who had the last laugh on a remarkable day at Lord's that saw 19 wickets fall in total.
First Published: July 9, 2017, 11:16 PM IST