Resuming the second day on 128-2, India were all out for 375 in the final session to claim a first innings lead of 192 runs and Sri Lanka's troubles did not end there. Teams:
Openers Dimuth Karunaratne and Kaushal Silva were both dismissed in the first two overs with the hosts reeling at 5-2 in their second innings at stumps, still trailing India by 187.
Earlier, Dhawan (134) and Kohli (103) frustrated the Sri Lankan bowlers with a 227-run stand that was the cornerstone of the Indian innings.
Bowled out for 183 in the first innings, Sri Lanka had a few half chances in the morning session but otherwise failed to trouble the batsmen on the slow pitch at the Galle International Stadium.
The hosts made a stronger comeback in the later sessions, riding on off-spinner Tharindu Kaushal's second five-wicket haul and three wickets from paceman Nuwan Pradeep.
Left-handed Dhawan, who scored 173 against Bangladesh in India's last test in June, hit a cover drive for four off paceman Dhammika Prasad to complete his fourth test century.
The 29-year-old, who was dropped on 28 and 122 during his knock, hit 13 fours in his patient 271-ball innings before he chopped paceman Nuwan Pradeep onto the stumps.
Kohli, in his first full series as India's test captain, hit 11 fours to complete his 11th hundred in tests but was out shortly after going past the three-figure mark.
The 26-year-old fell leg before after fluffing his sweep shot against off-spinner Tharindu Kaushal, who also dismissed Ajinkya Rahane lbw for a duck in his next over.
Pradeep brought the hosts the fourth wicket of the second session by castling Ravichandran Ashwin (seven), an over after he dismissed the well-set Dhawan.
Wicketkeeper Wriddhiman Saha (60) stretched India's lead with his maiden half-century before he became Pradeep's third victim.
Kaushal also dismissed Harbhajan Singh and Amit Mishra and took his fifth wicket with the dismissal of number 11 batsman Varun Aaron.
India: Shikhar Dhawan, Lokesh Rahul, Rohit Sharma, Virat Kohli (captain), Ajinkya Rahane, Wriddhiman Saha (wk), Ravichandran Ashwin, Harbhajan Singh, Amit Mishra, Varun Aaron, Ishant Sharma
Sri Lanka: Dimuth Karunaratne, Kaushal Silva, Kumar Sangakkara (wk), Lahiru Thirimanne, Angelo Mathews (capt), Dinesh Chandimal, Jehan Mubarak, Rangana Herath, Dhammika Prasad, Nuwan Pradeep, Tharindu Kaushal.
Resuming the second day on 128-2, India were all out for 375 in the final session to claim a first innings lead of 192 runs and Sri Lanka's troubles did not end there.