Paceman Jasprit Bumrah laid the foundation for India's victory with a career-best 5-27 to help restrict Sri Lanka to 217-9 at the Pallekele International Cricket Stadium.
India slumped to 61-4 in 14 overs but Sharma and Mahendra Singh Dhoni accomplished the chase with an unbroken 157-run stand to put India 3-0 up in the five-match series.
The match was held up towards the end when irate fans, who have been protesting since India blanked Sri Lanka 3-0 in the preceding Test series, hurled water bottles and forced the players off the ground for about half an hour.
Bumrah dismissed Niroshan Dickwella and Kusal Mendis to reduce Sri Lanka to 28-2 before Lahiru Thirimanne and Dinesh Chandimal tried to steady the innings.
Once Hardik Pandya dismissed Chandimal for 36, Sri Lanka lost wickets at regular intervals and did not get any significant partnership.
Bumrah dismissed Thirimanne for 80 and accounted for the wickets of Akila Dananjaya and Milinda Siriwardana.
India started their reply weakly.
Dananjaya's six-wicket haul had nearly derailed India's chase in the previous match and the off-spinner dismissed KL Rahul and the Kedar Jadhav cheaply to rekindle Sri Lanka's hopes of staying alive in the series.
Sharma's sensible batting, in the calming presence of former captain Dhoni, snuffed out home hopes as they calmly guided India home.
Sharma's 12th ODI century included two sixes and 16 boundaries. Dhoni hit a six and four fours in his 67 not out.
The teams move to Colombo for the fourth one-dayer on Thursday.