Fired-up Ben Stokes gives England hope of unlikely victory after Bairstow controversy
Stokes, angered when Bairstow was given out stumped by Alex Carey, struck three sixes in an over off Cameron Green to reach his century and was unbeaten on 108 at the interval with England needing another 128 to level the series.
After Ben Duckett fell for a battling 83, Bairstow had made 10 when he left his crease following a delivery from Green and wicketkeeper Alex Carey threw down the stumps.
With Bairstow out of his ground, the Australians celebrated wildly. Bairstow and Stokes looked bemused but Australia refused to withdraw the appeal and the right-hander trudged off to loud boos around the ground.
Stokes, clearly fired up to play another match-winning innings as he did in the 2019 Ashes, went on the attack.
He was dropped by Pat Cummins on 77, a hard caught-and-bowled chance, before his stunning assault on Green brought up his 13th test century off 142 balls.
Duckett and Stokes had batted cautiously after England resumed on 121-4, milking singles from the predominantly short-pitched bowling they faced.
Stokes, on 39, was given out lbw to Mitchell Starc but the batsman reviewed immediately and replays showed the ball had hit the bat before striking his pad.
Without the option of injured spinner Nathan Lyon, Cummins was forced to rotate his pace attack but with the sun popping in and out there was little assistance for the bowlers.
Josh Hazlewood made the breakthrough when Duckett tried to hook a bouncer and edged to Carey who took an excellent one-handed catch high above his head to end a partnership of 132 and reduce England to 177-5.
Bairstow had looked in good touch before his dismissal, which fired up the crowd and set the stage for Stokes, who took the opportunity in style to give the majority of the crowd hopes of a repeat of his heroics at Headingley in 2019.
Stuart Broad was unbeaten on one at the interval.