Left-handed Raina (76) and skipper Dhoni (71) put on 143 for the fourth wicket to raise India's hopes of reaching a big total on a slow pitch in the day-night match.
The tourists were all set for the late onslaught when they made 215-3 in 40 overs, but the dismissals of well-set Raina and Dhoni in quick succession pegged them back.
India lost seven wickets for 34 runs in the last nine overs, with left-arm seamer Thilan Thushara finishing with 5-45 for his maiden five-wicket haul.
Teenager Virat Kohli (54) put India on the right track with a maiden half-century after his captain won a fourth consecutive toss of the series, adding 44 for the opening wicket with Gautam Gambhir (17).
Sri Lanka struck back with three wickets in the space of 37 runs to reduce India to 81-3 before running into Raina and Dhoni, who batted sensibly against pace and spin to complete their second successive half-centuries.
Gambhir was the first to go, cutting seamer Nuwan Kulasekara straight to Tillakaratne Dilshan, who timed his jump to perfection to hold a brilliant catch at backward point.
Sri Lanka's left-arm seamer Chaminda Vaas then became the fourth bowler in one-day internationals to complete 400 wickets when he had Yuvraj Singh caught by skipper Mahela Jayawardene at short mid-wicket for no score.
Retired Pakistani pace duo Wasim Akram (502) and Waqar Younis (416), and Sri Lankan Muttiah Muralitharan (479), are others in the 400-club.
The 19-year-old Kohli had been batting confidently before inside-edging a Thushara delivery on to his stumps. He hit seven fours in his 66-ball knock.
Raina, who cracked 53 in the previous match, reached his seventh half-century with an aggressive shot when he lofted off-spinner Muralitharan over extra cover for a four.
He fell playing a big shot off Thushara in the closing overs, caught by Kulasekara at long-off after hitting one six and six fours.
The Indian skipper, who made 76 in the last match, completed his 24th half-century a few overs later, sweeping spinner Ajantha Mendis for two runs.
The tourists lead 2-1 in the five-match series.
India 258 all out in 49.4 overs (Raina 76, Dhoni 71, Kohli 54; Thushara 5/47, Vaas 1/40) Vs Lanka.