Chasing 276, India were down and out at 193 for seven before Deepak Chahar and Bhuvneshwar Kumar (19 not out off 28) forged an unbeaten 84-run stand to seal a memorable win for the visitors, who extended their record of not losing an ODI on Sri Lankasoil since 2012. A struggling Sri Lankan outfit badly needed a morale-boosting win but was only to blame for not finishing the job from a commanding position.
Chahar, whose highest score before this game was 12, showed remarkable resolve and composure under pressure to take his team over the line with five balls to spare. He fittingly hit the winning boundary. It was India's ninth consecutive bilateral series win over Sri Lanka.
The third ODI will be played on Friday. It was expected to be another comfortable chase for India after Sri Lanka improved batting effort to post 275 for nine.
However, a questionable shot selection from the majority of the Indian batsmen gave their struggling opponents hope.
Barring Chahar and Suryakumar Yadav (53), the Indian batsmen faltered. Leg-spinner Wanindu Hasaranga troubled the Indians with his variations and ended up being the stand out bowler for his team.
India felt the heat early on in the chase with Prithvi Shaw and Ishan Kishan, who blew away the opener's opposition on Sunday, getting out too bad shots.
Shaw failed to pick the wrong one off Hasaranga and got bowled while going for a cut. The opener once again showed sublime form during his short stay in the middle with three delightful boundaries before throwing it away.
With his feet nowhere close to the bat, Kishan tried to whack it through the off-side off pacer Kasun Rajitha only to play it onto the stumps, leaving India at 39 for two in four overs.
Skipper Shikhar Dhawan (29 off 38) was not at his fluent best for the second game in a row and was trapped in front by Hasaranga.
Manish Pandey (37) was unfortunate to be run out of a deflection from the bowler's hand and Hardik Pandya hitting it straight to mid-wicket with hard hands left India reeling at 116 for five.
Suryakumar and Krunal stitched a 44-run stand before Chahar produced a stunner from nowhere for a remarkable win.
Earlier, leg-spinner Yuzvendra Chahal led India's decent effort with the ball. Pretty much like the series opener, most of the Sri Lankan batsmen got starts but failed to capitalise after the hosts opted to bat.
Avishka Fernando (50 off 71) and Charith Asalanka (65 off 68) struck fine half-centuries, but the home team wasn't disciplined enough to post an imposing total.
Chamika Karunaratne (44 not out off 33) came up with another timely cameo to take the team past 270. Chahal (3/50) was the pick of the bowlers, while pacers Deepak Chahar (2/53) and Bhuvneshwar Kumar (3/54) too got wickets primarily due to the profligacy of the home team batsmen.
Openers Fernando (50 off 71) and Minod Bhanuka (36 off 42) took Sri Lanka to 59 for loss in the first 10 overs.
The momentum shifted India's way drastically after Chahal removed Minod and Bhanuka Rajapaksa off successive balls in the 14th over.
Sri Lanka, who are among the worst-performing teams in the middle overs, struggled again in the crucial stage of the game.
They took 97 balls to take find their next boundary after the eight over. From 77 for no loss in the 14th over, Sri Lanka slipped to 134 for four in the 28th over.
Asalanka and skipper Dasun Shanaka tried to resurrect the innings, but their 38-run stand ended with the captain falling to a flatter one from Chahal.
Asalanka got to his maiden fifty with a lofted boundary over extra cover off Kuldeep Yadav before sweeping the left-arm wrist spinner for another four in the same over.
Bhuvneshar kept things tight but bowled at a slower pace than his usual.