At lunch, England were 243 for eight.
Bairstow was unbeaten on 103 -- his second Test century and first in England following the Yorkshireman's 150 not out against South Africa at Cape Town in January.
But there was no maiden Test century for Alex Hales, who fell for 86.
Hales and Bairstow, dropped on 70, extended their overnight partnership to 141.
But the opener's dismissal sparked a collapse that saw England lose three wickets for nine runs as they slumped from 224 for five to 233 for eight.
More From This Section
Finn, backing up too far, might have been out had Kaushal Silva's throw hit the stumps after Bairstow played the ball to extra-cover.
But instead the ball went for three overthrow runs which allowed the 26-year-old Bairstow to complete a 145-ball hundred including 10 fours and a six.
England resumed on 171 for five, having collapsed to 83 for five after losing the toss on an overcast first day.
Hales was a Test-best 71 not out, with Bairstow unbeaten on 54 after Sri Lanka medium-pacer Dasun Shanaka had taken three top-order wickets on Test debut.
The busy wicket-keeper was soon into his stride, with the best of his shots Friday an on-driven four off Shanaka.
It was not long before he had outscored Hales, who was 43 not out when Bairstow came in.
Bairstow, however should have been out when Pradeep dropped a caught and bowled chance off a checked drive.
Sri Lanka also gave Hales a life when on 82 he edged Sri Lanka captain Angelo Mathews to second slip where a diving Dimuth Karunaratne dropped the sharp catch.
He faced 206 balls, including 12 fours.
Fast bowler Dushmantha Chameera then struck twice, with Moeen Ali caught at short leg for nought -- the third duck of the innings -- before Stuart Broad played on.