The hosts were all out on the stroke of lunch on the second day at Colombo's P. Sara Oval, after adding exactly 100 to their overnight 238-7, much to the frustration of the visitors who were playing their 100th Test.
Chandimal, who was unbeaten on 86 overnight, made 138 off 300 balls after an innings which contained more than its share of good fortune.
After surviving two TV reviews on the first day, he was again given out caught behind on Thursday off Mustafizur Rahman's bowling but the decision was overturned when replays showed the ball had not touched his bat.
Soumya Sarkar managed to grasp the catch after several fumbled attempts but Chandimal and Lakmal then continued to frustrate Bangladesh as they put on a 55-run partnership for the ninth wicket.
More From This Section
Off-spinner Mehedi finally dismissed Chandimal, who now has four Test centuries against Bangladesh in six Tests, as debutant Mosaddek Hossain took the catch at midwicket.
Chandimal, who struck only four boundaries on the opening day while helping his side recover from 70-4, batted aggressively on the second day to hit 10 fours and a six overall in his innings.
Mehedi finished with 3-90 for Bangladesh.