Murali Vijay was unbeaten on 39 and Ajinkya Rahane was on 28, the pair having added 67 runs for the second wicket after Lokesh Rahul was dismissed off the fifth ball.
India will begin the fourth day’s play on Sunday with a lead of 157 runs and nine wickets in hand.
Sri Lanka were all out for 306 after tea in reply to India’s first innings total of 393, with skipper Angelo Mathews making 102, his sixth Test century.
Leg-spinner Amit Mishra finished with four wickets, while seamer Ishant Sharma and off-spinner Ravichandran Ashwin claimed two each.
Sri Lanka lead the three-match series, having won the first Test in Galle by 63 runs.