You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
Having built an impressive base after being inserted on a lively pitch, the Afghans were dismissed for 232 with two balls remaining.
Former Sri Lankan captain Mahela Jayawardene guided his side to a four-wicket triumph with a fine century - his 19th ODI ton.
But the victory was not without hiccup. A crowd of 2711 watched as Sri Lanka made the worst possible start, losing opener Lahiru Thirimanne lbw first ball and then Tillakaratne Dilshan also without scoring.
It was only the second time in ODI history both openers recorded first ball ducks.
Kumar Sangakkara was bowled for seven and watched as the bowler Hamid Hassan celebrated with a part cartwheel, part high-speed forward roll.
There was more extravagant celebration when Dimuth Karunaratne (23) gave some catching practice to Mangal in the slips. This time Hassan got down on one knee and looked skyward with his arms splayed.
It was a great moment for the Afghans but experienced campaigner Jayawardene and the skipper Angelo Mathews gradually rebuilt the innings.
The pair added 126 runs in a crucial partnership.
Jayawardene went on to post his 19 ODI hundred. He worked the ball of his hip for a single to bring up the milestone.
The Sri Lankan section of the crowd greeted his ton with a not-so raucous round of song.
They had been silenced when Mathews had been run out for 44 moments earlier. When Jayawardene guided a catch to third man shortly after, the match appeared to have another twist waiting.
There was no further calamity for Sri Lanka. Thisara Perera and Jeeven Mendis held their nerve. Perera played a clutch innings, whacking an undefeated 47 from 26 deliveries.
The outcome may well have been different had Afghanistan been able to capitalise on a very useful opening 35 overs.
It was well-placed at 169 for four and a score of 300 was within reach.
But the second batting power player proved decisive, however not for the batting side. Afghanistan netted just 10 runs and it cost the princely sum of two wickets.
The turning point came when Sri Lankan kingpin Lasith Malinga beat the swinging bat of Mohammad Nabi.
The last 10 overs were only a marginal improvement.
They yielded more wickets, dots and singles than fours or sixes. Ultimately that was the difference between the two teams.
Afghanistan's next assignment is against Scotland in Dunedin on Thursday and Sri Lanka play Bangladesh in Melbourne on the same day.