India, in reply, lost Lokesh Rahul (five) to reach 23 for one wicket at stumps, still needing another 153 runs for victory. First-innings centurion Shikhar Dhawan (13) and nightwatchman Ishant Sharma (five) were unbeaten at the crease.
The tourists seemed to be cruising towards an inning victory after picking up three wickets in the morning but wicketkeeper-batsman Chandimal (162 not out) and Lahiru Thirimanne (44) stemmed the rot by adding 125 for the sixth wicket.
Chandimal, 25, stitched together another 82-run stand for the seventh wicket with Jehan Mubarak (49) during his 169-ball knock, which included 19 boundaries and four sixes, before the hosts were all out for 367 in their second innings.
The right-handed batsman walked into bat with Sri Lanka on 92-4 and it became 95-5 in the next over forcing him to launch a counterattack.
Chandimal, who was reprieved by a wrong decision by the umpire with him on single digit, played the sweep shot ferociously against the spinners and also employed the reverse sweep to good effect and picked up boundaries at will.
After a successful morning session for the visiting bowlers, Thirimanne was the only batsman to fall in the afternoon session.
Off-spinner Ravichandran Ashwin, who picked up six wickets in the first innings, took his third in the second by sending back Thirimanne after a catch by Ajinkya Rahane at slip.
Ashwin also clean bowled number 11 batsman Nuwan Pradeep to finish with a match haul of 10 wickets.
Sri Lanka, bowled out in their first innings for 183, resumed the day on five for two wickets after dismissing India for 375 but lost nightwatchman Dhammika Prasad (three) on the first ball of the morning by fast bowler Varun Aaron.
Prasad could not handle the steep bounce Aaron extracted off the Galle International Stadium pitch and gloved the ball to Rahane at gully.
The dismissal brought home captain Angelo Mathews to the crease and he stitched together a defiant 87-run stand for the fourth wicket with retiring stalwart Kumar Sangakkara.
Mathews (39) suffered a painful blow to his body off fast bowler Ishant Sharma early in his innings and decided to take the attack to the Indian bowlers.
The experienced duo managed to keep the tourists at bay for over 90 minutes in the session before Rahane pulled off an excellent catch at slip off Ashwin to send back Sangakkara (40).
The 37-year-old, who will retire after the second test against India in Colombo, walked off to a standing ovation.
India captain Virat Kohli then introduced Amit Mishra, who had taken a wicket in his first over on Thursday evening, and the leg-spinner took out Mathews, who edged a catch to Lokesh Rahul at silly mid-off.
Mishra, playing his first test for India in four years, should also have had the wicket of Thirimanne after the left-hander fell to a bat-pad catch but the umpire ruled it as not out.