At stumps on day one England, hunting a 3-0 whitewash, were 312-7, Bairstow having made 110 after partnerships of 100 with Joe Root and 99 with Ben Stokes.
"I was obviously pleased with it. There's only a few times you get to score a hundred for England, so it's a special time to be out there in the middle," Bairstow, 29, said afterwards.
"The emotion and hard work that has gone into getting back out on the field is massive."
Left-arm wrist spinner Lakshan Sandakan was Sri Lanka's most penetrative -- and expensive -- bowler of the day, taking 4 for 91 off his 21 overs.
Finger spinners Malinda Pushpakumara and Dilruwan Perera shared the other three wickets between them.
Batting after Root won his eighth straight toss, England lost both openers cheaply in the morning.
Rory Burns disappointed again, bowled by Perera for 14 as he tried to cut. Keaton Jennings fell three overs later, caught at leg slip off Pushpakumara for 13.
But Root and Bairstow, England's fourth different number three in the series, steadied the ship, surviving one review each to steer the visitors to 102-2 at lunch.
Bairstow and Root put on a 100-run stand before the captain fell to Sandakan after lunch, top-edging an attempted slog sweep on 46.
Sri Lanka should have had Stokes as well, with umpire Chris Gaffaney incorrectly turning down Perera's lbw appeal when the Durham allrounder was yet to get off the mark.
Stokes and Bairstow then made hay, Stokes hitting five fours and two sixes before Sandakan got the Durham all-rounder to edge to slip, his 57 scored off 88 balls.
Bairstow then passed his century, removing his helmet and celebrating with gusto.
But he fell for 110, another Sandakan scalp, and was soon followed by Buttler for 16, caught and bowled by the same man, and by Ben Foakes who nicked Pushpakumara on 13.
Moeen Ali, who has had a woeful tour with the bat -- in contrast to with ball in hand -- then survived an lbw review. He ended on 23 and Adil Rashid not out on 13.
Sri Lanka also dropped two straightforward chances off Ali, who edged to wicketkeeper Niroshan Dickwella on two and to slip Dimuth Karunaratne on 17.
Not Given up Keeping
The ginger-haired Bairstow was installed at the key number three spot after Ali got a duck and three in the first Test and after an experiment with Stokes in Kandy failed to pay off.
But Bairstow on Friday stopped short of saying he has now made the position his own with his century, his sixth.
"Long term who knows what's going to happen. In the last year I think I've batted at 7, 6, 5, 4 and three. Who knows what's going to happen long term but I'm happy with my performance today," he said.
Injuring himself playing football before the Galle Test, he was then left out in Kandy after his replacement at wicketkeeper, Foakes, hit a blistering century -- and on his Test debut.
Bairstow made clear Friday though that he hasn't hung up his gloves just yet.
"I’ve not given up my keeping, I want to make that very, very clear. I'm still working hard on my keeping because it's something I still want to do," he said.
Ben StokesDanushka GunathilakaJonny Bairstowlakshan sandakanMoeen AliSri Lanka vs Englandsri lanka vs england 2018
First Published: November 23, 2018, 6:07 PM IST