Thirimanne made 155 not out and Chandimal was unbeaten on 116 as they recorded a fifth-wicket stand of 203 to take Sri Lanka to a first innings total of 570 for four declared at tea on Saturday.
Buoyed up by the batsmen, Sri Lanka's bowlers made an early breakthrough, capturing the wickets of openers Jahurul Islam and Anamul Haque.
Bangladesh, though, fought back with an unbeaten half-century from Mohammad Ashraful to end the day on 135-2 at the Galle International Stadium.
Jahurul (20) was out as he tried to get out of the way of a delivery from Shaminda Eranga but only succeeded in gloving a catch to Chandimal.
Ajantha Mendis, playing his first Test since May 2011, took a wicket off his first over when he bowled Anamul with a flighted delivery for 13.
Ashraful (65 not out) and Mominul Haque (35 not out) stopped Sri Lanka making any further inroads to their batting with an unfinished stand of 70.
"Neither the spinners nor fast bowlers can get much out of the pitch which is very flat," said Thirimanne.
"We are in a good position but with the pitch being flat the bowlers will have to bowl in good areas to bowl Bangladesh out."
Bangladesh needed a further 236 runs to avoid the follow-on.
Earlier, Chandimal brought up his first Test hundred off 136 balls with the aid of 11 fours and two sixes, the 23-year-old making the most of his luck after the tourists had twice dropped him earlier in the innings.
Thirimanne, whose previous highest score was 91 against Australia in Sydney early this year, completed his maiden Test century in the morning session.
Having earlier missed out on a Test hundred, Thirimanne was patient as he carefully picked through 66 balls to score the required 26 runs he needed, having started the day on 74 not out.
"I think I batted really well and it was a great day for me," said the left-hander who struck nine fours in his 193-ball innings.
"The innings of 91 against Australia at Sydney was a bit more challenging than this but I felt happy about my maiden Test century."
Bangladesh's only success with the ball came in the fourth over of the day when Angelo Mathews was dismissed for 27.
The Sri Lankan captain tried to manufacture a shot that was not there and chipped a leading edge which the bowler Abul Hasan gladly accepted.
- Sports & Recreation
- Sri Lanka