Replying to Australia's 416-8 declared, England were reeling on 57-4 with the spectre of follow-on looming large when Australia skipper Pat Cummins brought back Green for another spell.
Stokes left the first ball of the 31st over which deviated as it passed the batsman and umpire Paul Reiffel upheld Australia's vociferous appeal for an lbw.
While the home side celebrated the dismissal, Stokes immediately reviewed it and replays confirmed the ball was nowhere near the pad and had hit the top of the off-stump though the impact was not enough to dislodge the bail.
The lbw decision was overturned and Stokes, then on 16, could not suppress his glee at the reprieve before he resumed batting.
"He knew that it definitely had not hit the pad," Jonny Bairstow, whose 103 not out was England's first century of the series, told reporters afterwards.
Stokes had been rewarded with another "life" when Cummins spilled a sharp return catch when the batsman was on nine.
The all-rounder went on to score 66, his first half-century of the series, before off-spinner Nathan Lyon trapped him lbw.
Stokes' 128-run partnership with Bairstow steadied England who, at 36-4, risked being subjected to follow-on but went on to finish the day on 258-7.
Stokes sustained a left side strain on Thursday and looked in discomfort when playing the pull and sweep shots.
Bairstow also batted through pain having suffered a blow to the thumb from a Cummins delivery but went on to bring up his seventh Test hundred which included three sixes.
"I'm absolutely over the moon...It's the hardest one so far," Bairstow said of his knock.
The 32-year-old needed medical attention to carry on and lead England's fight to salvage some pride with Australia having already taken an unassailable 3-0 lead in the series.
"Yes it was sore but obviously with the circumstances of the game, it was one of those decisions I made to stay out there."
"The medics can give you advice, but ultimately you are out there playing an Ashes New Year's Test match on a pink day in Sydney in front of the crowd. It's going to take a lot to get me away from that."