Afghanistan ambush Sri Lanka to continue memorable World Cup campaign
Their bowlers had laid the foundation of their third win in six matches when they bowled out Sri Lanka for a below-par 241 in 49.3 overs.
Three of their top five batters, including Shahidi, then produced half-centuries in a clinical chase which they accomplished in 45.2 overs to move to the fifth place in the points table.
Azmatullah Omarzai (73) scored the winning run with Shahidi (58) looking on from the other end.
Shahidi and his men had stunned holders England and 1992 champions Pakistan earlier in the competition and they proved those were no flukes with yet another impressive display against Sri Lanka.
Put into bat, several Sri Lankan batters got their eyes in but could not quite capitalise on those starts.
After the fall of Dimuth Karunaratne in the sixth over, Kusal Mendis (39) forged half-century partnerships with Pathum Nissanka (46) and Sadeera Samrawickrama (36) to steady the innings.
At 134-2 in the 28th over, Sri Lanka looked well placed to reach the 275-mark but the plucky Afghans struck at regular intervals to peg them back.
Angelo Mathews and Maheesh Theekshana raised 45 quick runs for the eighth wicket but Sri Lanka still fell short of the 250-mark.
Afghanistan lost Rahmanullah Gurbaz in the first over but Rahmat Shah (62) and Ibrahim Zadran (39) calmed the nerves with a 73-run partnership.
Kasun Rajitha dismissed Rahmat but not before the batter had brought up his second successive fifty of the tournament.
Shahidi and Omarzai mixed caution with occasional aggression in their unbroken century stand to take Afghanistan closer to the target.
With victory in sight, both decided to play their shots and Azmatullah scored the winning run when he attempted to hit a six and was dropped at deep midwicket.