Hashim Amla, playing at Old Trafford, made 53 in that innings.
England closed on 224-8 on a gloomy Sunday in Manchester, 360 ahead and, on a pitch offering intermittent sharp turn and variable bounce, are strong favourites to claim the Test and secure a 3-1 series success.
Ali finished South Africa off with two wickets in two balls to get tailenders Morne Morkel and Duanne Olivier.
Moeen passed his 50 with his second six, hoisted over long-on into the pavilion where it was caught by England wicketkeeper Jonny Bairstow - much to the amusement of captain Joe Root.
Earlier, Moeen, both Man of the Match and Man of the Series, made 75 not out off just 66 balls in England's second innings 243, having been dropped on 15.
"We needed a bit of momentum and it came off for me", Ali told Sky Sports.
'The selectors have to be smart: You're looking to fill key positions at the Gabba, not take relatively easy runs off West Indies'.
Earlier, Stuart Broad removed Olivier as the Proteas, nine down overnight, were dismissed for 226.
After establishing a healthy first-innings lead of 136, England lost three wickets either side of lunch.
One consolation for Anderson, who'd struck four times from the newly-named James Anderson End on Saturday, was that an innings return of four for 38 in 17 overs was his best in seven Tests on his Lancashire home ground, surpassing his four for 118 against New Zealand in 2008.
Anderson, now bowling from the Brian Statham End, started to bowl from around the wicket and Kagiso Rabada chipped him straight to Tom Westley at cover.
Moeen is only the second England Test player, behind Sir Ian Botham against India in 1979, to score more than 200 runs and take 20 wickets in a four-match series.
England were bidding for a first home Test series win over South Africa since 1998 at 2-1 up with one to finish in this four-match contest.
The same can not be said of Dawid Malan, whose place must now be in jeopardy after his latest failure saw him make just six before offering a simple chance to Theunis De Bruyn at short leg off the bowling of Maharaj.
Pace bowler Olivier, called up for this match after back injuries ruled out both Vernon Philander and Chris Morris, had taken two wickets for 13 runs in eight overs.
"If we can bowl them out for 380, I still believe it is possible", he said.
- Maduro says country facing 'armed insurgency,' thrashes chief prosecutor
- Special counsel Robert Mueller impanels grand jury as Trump-Russia investigation accelerates
- Shivakumar apologizes for his mother's statement accusing Siddaramaiah over IT raids
- Vice President Election 2017: Voting underway
- 'Clock is ticking' on Brexit warns Irish leader
- Stephen Colbert Gives Hilarious Reaction To Anthony Scaramucci's White House Exit
- Google rebukes employee's gender gap memo
- Wembley test for Chelsea, Arsenal after tough offseason
- Rahul Gandhi's auto attacked in Gujarat, SPG commando injured
- Samsung Galaxy S8 Active accidentally confirmed by AT&T?