Pace bowler Deepak Chahar hammered 69 off 82 deliveries and shared an unbeaten 84-run partnership for the eighth wicket with Bhuvneshwar Kumar to bring India back from the dead and win the second One-day International by three wickets for an unassailable 2-0 lead in the three-match series.
Sri Lanka had made 275/9 in their 50 overs while India reached the target with five balls to spare.
The Indian team looked down and out after left-handed batsman Krunal Pandya was dismissed as the seventh man with the team score on 193. Although there were 89 deliveries to get the remaining 83 runs, India had only three wickets left.
But Chahar played calmly, hitting seven fours and a six while vice-captain Bhuvneshwar scored 19 off 28 deliveries and importantly guided his junior through the chase.
India were caught by surprise as the Sri Lankans brought in leg-spinner Wanindu Hasaranga in just the third over of the innings. The leggie's googly beat Prithvi Shaw (13 off 11 balls) who was bowled.
Hasaranga got the other two important wickets of Shikhar Dhawan (29 off 38) and Krunal Pandya (35 off 54 balls) to leave India tottering. However, Hasaranga could not find support from the other bowlers.
Earlier, Chamika Karunaratne's unbeaten 44 off 33 balls towards the end of the innings took Sri Lanka to 275 for nine in their allotted 50 overs.
Opener Avishka Fernando (50 off 71 balls) and batsman Charith Asalanka (65 off 68 balls) scored half-centuries to lead the Lankans to a challenging total.
Leg-spinner Yuzvendra Chahal (3/50) and Bhuvneshwar Kumar (3/54) were the most successful bowlers for India. Seamer Bhuvneshwar got rid of both the half-centurions after Chahal had got the first two wickets.
This was India's 93rd win over Sri Lanka, the most by a team against a particular team in ODI cricket.
India had won the first ODI on Sunday by seven wickets.
Brief scores: Sri Lanka 275/9 in 50 overs (C Asalanka 65, A Fernando 50, C Karunaratne 44 not out, Y Chahal 3/50, B Kumar 3/54) lost to India 277/7 in 49.1 overs (D Chahar 69 not out, S Yadav 53, M Pandey 37, K Pandya 35, W Hasaranga 3/37) by three wickets