At stumps on the second day, Sri Lanka had collapsed to 91 for eight, a huge deficit of 407 runs, after Ali's Test-best 155 not out had propelled England to 498 for nine declared.
Woakes, only playing in this match because fellow seam-bowling all-rounder Ben Stokes was injured, took three wickets for five runs in 13 balls to reduce Sri Lanka to 67 for six.
Rangana Herath (12) gamely resisted for over an hour before fending Stuart Broad to gully.
Lahiru Thirimanne was 12 not out at the close and Suranga Lakmal unbeaten on nought.
England were now looking at their second innings victory in as many matches after their innings and 88-run win in the first Test of this three-match series at Headingley last week.
Another dire day with the bat for Sri Lanka, shot out for 91 and 119 at Headingley, was made all the worse by a wretched fielding display that was in marked contrast to yesterday's brilliant catching.
Kusal Mendis, who made a gutsy fifty in Sri Lanka's second innings at Headingley, was undone by a delivery that bounced more than he expected and lobbed a gentle catch to gully.
Mendis's 35 was easily the best score of the innings so far.
Five balls later, Woakes had Milinda Siriwardana edging to wicket-keeper Jonny Bairstow for a duck.
Woakes, who came into this match on the back of a career-best nine for 36 for Warwickshire against Durham, had now completed a double-wicket maiden at a sun-drenched Riverside.
Promoted to No 7 from No 8 in Stokes's absence, left-hander Ali, who made his name as a top-order batsman with Worcestershire but has been used mainly by England as an off-spinner, produced a fine array of shots.
England resumed today on 310 for six, with Ali 28 not out
and Woakes eight not out.
It was not long before both batsmen were reprieved, with Ali missed when Dimuth Karunaratne dropped a shoulder-high chance at a wide second slip off Nuwan Pradeep.
Even allowing for the fact Chandimal was nursing a thumb injury suffered Friday, this was still an extraordinary error.
The drinks break saw Mendis, one of several wicket-keeper/batsmen in Sri Lanka's squad, replace Chandimal behind the stumps.
Ali went to his hundred in style, driving paceman Pradeep on the up for four.
He had made 105 when he miscued a pull off Eranga, only for Siriwardana to make a complete hash of the opportunity on the boundary.
Left-arm spinner Herath claimed his 300th Test wicket by taking his team-mates out of the issue with a caught and bowled dismissal of Steven Finn.
But such was England's dominance against an attack where four bowlers conceded more than 100 runs each, No.11 Anderson got off the mark by reverse-sweeping Herath for four.
Ali faced 207 balls, including 17 fours and two sixes, in his near five-hour innings before England captain Alastair Cook declared.
