Joe Root's team have already lost any chance of regaining the urn, having suffered defeat in the opening three Tests, and they looked down and out at 36-4 at the Sydney Cricket Ground early in Friday's play.
However, Ben Stokes (66) and Bairstow put on a fifth-wicket stand of 128 to guide the tourists to 164.
Stokes' battling innings, in which he was struggling with an apparent side strain, came to an end when he misjudged a Nathan Lyon delivery and was trapped lbw, and England looked in danger of failing to avoid the follow-on when Jos Buttler got out cheaply for a duck.
Yet Bairstow and Mark Wood (39) fought back, with the latter hitting three sixes during an entertaining 41-ball spell that was ended by Pat Cummins.
Bairstow stayed at the crease, though, and cut Australia's captain for four to surpass 100 in the final over of the day, with England closing on 258-7, 158 runs behind.
It was Bairstow's seventh Test century, and his first since 2018, while no England player had scored an Ashes 100 in Australia since Alistair Cook back in 2017, with England's then captain scoring 244 on that occasion.
Bairstow was not selected for the first two Tests but returned to the fold in Melbourne, scoring 35 in the first innings and five in the second.
The 32-year-old, who made his Test debut in May 2012, also moved onto 1,033 runs scored against Australia.
Bairstow was clearly overjoyed when he celebrated his century. It was a poignant moment, with this Test having started on the 24th anniversary of the death of his father David, himself a former England wicketkeeper.
"Extremely proud, really, really proud. You've known me for long enough and how much that means," Bairstow told BT Sport. "Unbelievable, I was ecstatic, extremely proud, there's a lot of hard work gone into that one.
"It's been tough, you've got to dig deep, you really have. People mention the scheduling, how much red-ball cricket people are playing leading into massive series like this, it's not just this series, it's the India series, the India series before that when we were over there.
"You've got to delve very deep, on things you've worked hard at over a number of years.
"Tried not to be too rigid. You can look at technique a lot. Some things work but other times you've got to keep being natural about the way you're moving or you become a bit clunky and too rigid. That's what I feel sometimes got to, trying to be something potentially that I'm not.
"My strength is putting pressure back on the bowlers, running between the wickets, trying to get them off the length to then give me a different ball. I wasn't necessarily doing that, but that also comes with spending time out in the middle consistently."
Bairstow took a nasty blow to his thumb from a rapid Cummins delivery just after Stokes' dismissal, but fought through the pain barrier.
"Slightly sore, it's starting to get a bit sorer now we've come off the field," he said. "I was hurting!
"You're playing in a New Year's Test match in Sydney, on the Pink Day, it's going to take a heck of a lot to get you off the field. You've still got a job to do. Yes it's sore, it will be sore, but you're playing cricket for England and I'm very proud to do that."
An England victory still looks incredibly unlikely but, with rain possibly in store over the coming days, a draw is on the cards as the tourists aim to avoid a 5-0 whitewash.
"We've got two days to scrap and scrap hard," Bairstow added.
"We had a challenge this morning to still be batting at the end of the day. They've got a new ball coming, so tomorrow is about scrapping hard again. We got to the follow-on and past that, let's see how close we can get."