You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
The 1996 World Cup champions limped to 201 all out in the 37th over as Afghanistan grabbed nine wickets for 57 runs to give themselves a chance of pulling off a shock win.
Afghanistan needed a rain-revised target of just 187 from 41 overs but they failed to gain any momentum in their run chase and completely lost their way after opener Mohammad Shahzad's dismissal in the fifth over led them to losing five wickets for just 23 runs.
After Afghanistan were reduced to 57-5, a partnership of 64 by Najibullah Zadran and captain Gulbadin Naib gave them hope.
But fast bowler Nuwan Pradeep grabbed two quick wickets before Najibullah was run out by Dimuth Karunaratne for 43.
That set up a tense finale as the last two batsmen needed to score another 42 runs to hand Afghanistan their first World Cup win against a test-playing nation.
But Sri Lanka made sure that victory did not come at their expense as Lasith Malinga bowled Hamid Hassan with a yorker four balls later.
Pradeep was the pick of the Sri Lankan bowlers as he claimed a career best four wickets for 31 runs as Afghanistan were bowled out for 152 in the 33rd over.
"One hundred and eighty seven is not easy to defend, we know their openers go hard, but once we got them they were on the backfoot and we kept getting wickets," Sri Lanka captain Karunaratne said.
Earlier, Sri Lanka's batsmen had also lost their way as they fell from 144-1 to 201 all out.
Mohammad Nabi sparked the collapse when he grabbed three wickets in the space of five deliveries by producing a brilliant spell of spin bowling in the 22nd over. He finished with four wickets for 30 runs.
Sri Lanka slid steadily to 182-8 before play was paused due to rain.
Some big hits by the tailenders carried Sri Lanka over the 200 run mark after play resumed. Wicketkeeper-batsman Kusal Perera top-scored with 78 runs off 81 balls which included eight boundaries.
But he ran out of partners at the other end and holed out in desperation.
"The wicket was not easy for the batsmen and so we'd asked the bowlers to hit the deck hard and they came back well during the middle overs," said Afghanistan skipper Naib.
The win over Afghanistan handed Sri Lanka their first win of the tournament after they were beaten by South Africa in their opener. Afghanistan are rooted to the bottom of the 10-team standings having lost both of their matches.