Thirimanne, whose previous highest score was 91 against Australia at Sydney early this year, was 113 not out when Sri Lanka took lunch at 461 for four wickets at the Galle International Stadium.
Dinesh Chandimal was unbeaten on 55 alongside Thirimanne, with the fifth wicket partnership worth 94 runs.
The pair came together when Angelo Mathews was dismissed for 27 in the fourth over of the morning.
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.
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.
The left-hander struck nine fours in his 193-ball innings for his century.
Chandimal batted uncharacteristically to reach his half-century before lunch off 91 balls, offering two catches to the tourists which were both dropped.