Ajinkya Rahane scored 126 and Murali Vijay made 82, the pair adding 140 for the second wicket after Lokesh Rahul had been dismissed off the fifth ball on Saturday.
At tea, Stuart Binny was unbeaten on 17 and Ravichandran Ashwin was on three.
Sri Lanka made 306 in their first innings in reply to India's 393.
Sri Lanka lead the three-match series, having won the first Test in Galle by 63 runs.