South Africa already needed to set a new ground record if they were to end this four-match series all square at 2-2, with England's 294 for four against New Zealand in 2008 the most any side have yet made to win in the fourth innings of a Test at Old Trafford.
Off-spinner Ali has been a thorn in South Africa's side with both bat and ball this season.
This innings meant he'd now scored 200 runs and taken 20 wickets in the series, with Ali the first England player to perform that 'double' since Andrew Flintoff in the 2005 Ashes.
Ali made South Africa pay for Dean Elgar dropping him on 15 when a low slip chance off left-arm spinner Keshav Maharaj did not stick.
He may come in at No 8 for England but Ali has spent most of his career with Worcestershire as a top-order batsman.
Ali, who bats left-handed, was especially severe on Maharaj, hitting him for three resounding sixes.
The second of those, a straight drive that saw Ali complete a 49-ball fifty — was 'caught' on the England dressing-room balcony by wicket-keeper Jonny Bairstow to the delight of the crowd.
"We needed a bit of momentum and it came off for me," Ali told Sky Sports. "Sometimes you have to take the odd risk."
England are bidding for a first home Test series win over South Africa since 1998, with Root seeking a victory in his first Test series as England captain.
South Africa resumed on 220 for nine and were soon all out for 226 when Stuart Broad dismissed last man Duanne Olivier.
That gave England a healthy first-innings lead of 136.
Olivier's exit meant James Anderson, England's all-time leading wicket-taker -- was denied a maiden five-wicket Test innings haul on his Lancashire home ground.
But figures of four for 38 in 17 overs gave Anderson, who'd struck four times from the newly-named James Anderson End on Saturday, his best innings return in seven Tests at Old Trafford.
South Africa fast bowler Morne Morkel then removed both Alastair Cook (10) and Tom Westley (nine) with the aid of gully catches.
Keaton Jennings, dropped on nought, fell for just 18 when he edged a cut off Kagiso Rabada to first slip Hashim Amla.
It was the latest in a run of low scores -- the South Africa-born opener managed just 127 runs in four Tests this series at an average of 15.88 -- that have left Jennings at risk of being dropped for the start of England's upcoming three-Test series at home to the West Indies, which precedes an Ashes tour of Australia.
Dawid Malan, out for scores of one and 10 on Test debut during England's 239-run victory in the third Test at The Oval, was also looking to cement his place after falling for 18 in the first innings of this match.
But the Middlesex left-hander, born in London but brought up in South Africa, exited for six -- having been dropped on five -- when caught via bat and pad at short leg off Maharaj.
Root (49) and Ben Stokes (23), however, then shared a valuable stand of 57.
They both fell to paceman Olivier, only playing this match after back injuries ruled out both Vernon Philander and Chris Morris.
Olivier, who took an impressive three for 38 in total, insisted South Africa could yet achieve a remarkable win.
"If we can bowl them out for 380, I still believe it is possible," he said. "England batted really well but we still have a chance.
"It is going to be difficult but it should be -- it's Test cricket."
Ben StokesDean ElgarEngland vs South Africa 2017Faf du PlessisJoe RootJonny Bairstowkeshav maharajMoeen Ali
First Published: August 7, 2017, 8:40 AM IST