India's total was the highest posted by any visiting team in an ODI in Sri Lanka, bettering their own record of 363 for 5 at the same ground in 2009.
Courtesy skipper Kohli's (131 off 96 balls) 29th ODI hundred and his 219-run second-wicket stand with an in-form Sharma (104, 88 balls), India were able to lay the foundation for an imposing total.
Sharma, who hit back-to-back hundreds, now has 13 three- figure scores in the 50-over format.
Incidentally, Dhoni got a single off the penultimate delivery of the 50th over as he remained stranded on 49 not out -- one short of what could have been his 100th international half-century.
More From This Section
The Dhoni-Pandey unbroken partnership for the sixth wicket yielded 101 runs in only 12.2 overs.
After winning the toss on a batting belter, skipper Kohli joined Sharma after Shikhar Dhawan (4) was dismissed trying to slash an Angelo Mathews delivery over point.
The first 50 came off 52 balls, but the innings slowly gathered pace as India crossed 100 off just 84 balls.
Kohli raced to his half-century off 38 balls even as their 50 partnership came off 46 balls.
The hectic pace of scoring continued as Kohli and Sharma celebrated their 100 partnership off only 76 balls with the latter also reaching half-century off 45 balls.
Kohli faced 96 balls and hit 17 fours as well as 2 sixes while Sharma's innings had 11 boundaries and three maximums.
Their partnership improved on the previous highest 2nd wicket stand on Sri Lankan soil -- 197 runs added by Dhawan and Kohli in the first ODI of this current series in Dambulla.
It was also India's third-highest 2nd wicket partnership against Sri Lanka in ODIs, after 318 at Taunton in May 1999, and 236 at Nagpur in March 1999 -- both set by Sourav Ganguly and Rahul Dravid.
This was also their third 200-plus stand as a pair equalling the record held jointly by Sachin Tendulkar and Ganguly, as well as Gautam Gambhir and Kohli.
Akila Dananjaya (1/68 in 10 overs) also did not cause any trouble to the batsmen.