He was in danger of running out of partners as Alex Hales fell 14 short of a maiden test century and two more quick wickets followed.
The hosts had been 83 for five at one stage on the truncated first day’s play, before Hales and Bairstow came to the rescue with a stand of 141.
Then opener Hales, having taken 20 minutes to add to his overnight 71, decided to open up against left-arm spinner Rangana Herath and Dushmantha Chameera took a good catch running in from deep extra cover.
Chameera then claimed two wickets in one over, having Moeen Ali caught at short leg for a duck and bowling Stuart Broad for two.
Bairstow should have been dismissed on 70, offering a straightforward caught-and-bowled to Nuwan Pradeep, but he survived to reach his second test century on an overthrow and was 103 not out at lunch.