Set a Duckworth-Lewis target of 163 in 26 overs, the hosts survived anxious moments before winning with seven balls to spare at the Premadasa stadium to grab the lead in the three-match series.
Dilshan hit six boundaries and three sixes before Sri Lanka floundered while chasing the revised target after the West Indies, sent in to bat, had scored 159-8 in their 26 overs.
The hosts, cruising at 104-2, lost seven wickets for 48 runs before tailender Ajantha Mendis hit the winning six off Johnson Charles in the company of last man Suranga Lakmal.
The start of the day-night match was delayed by an hour and 20 minutes due to persistent rain. Further bad weather during the West Indies innings reduced the game to 26 overs-a-side.
Dilshan put on 46 for the first wicket with Kusal Perera and 43 for the second with Lahiru Thirimanne to give Sri Lanka a bright start.
But spinner Sunil Narine claimed three wickets, and Carlos Brathwaite and Jonathan Carter took two each, to cause a sensational Sri Lankan collapse when all seemed lost for the West Indies.
Sri Lankan captain Angelo Mathews admitted his side was “lucky” to win the match.
“It was a lucky escape,” he said. “We made a real mess out of the game. But the lesson has been learnt.
“The bowlers did a great job, but we should have finished the game sooner than we did. It was good to see Mendis take up the challenge with the bat.”
West Indies skipper Jason Holder said it was hard to lose a game which his team had come so close to winning.
“It was a tough loss since we came so close at the end,” he said. “But I am not too disappointed. Credit to the boys for fighting back both with the bat and the ball.”
Andre Russell and Darren Bravo put on 58 runs off 37 balls to steer the West Indies to 159-8 after they slipped to 24-3 before the rain break and then became 42-4 soon after resumption.
Russell smashed three sixes and as many fours in 41 off 24 balls and left-handed Bravo chipped in with 38 during an entertaining fifth-wicket stand to retrieve the situation.
Skipper Holder then hit 36 off 13 balls with three sixes and two boundaries as the West Indies plundered 59 runs in the final five overs.
Lakmal claimed the first three wickets and spinner Mendis took two.
Sri Lanka swept the preceding Test series 2-0. The second one-dayer will be played at the same venue on Wednesday.
The one-day series will be followed by two Twenty20 games.