Mahela Jayawardene came to the rescue with a century as Sri Lanka made hard work of beating Afghanistan in their World Cup clash at the University Oval in Dunedin.
Chasing a modest 233 to claim their first Pool A victory, Sri Lanka slipped to 51 for four in the 12th over.
But Jayawardene anchored the innings with 100 and, after Angelo Mathews made 44 in a 126-run fifth-wicket stand, Thisara Perera’s unbeaten 47 off 26 deliveries led Sri Lanka home with four wickets and 10 balls to spare.
Asghar Stanikzai's half-century and several useful contributions helped Afghanistan to 232 all out after losing the toss.
They slipped to 40 for two in the 10th over before Stanikzai and Samiullah Shenwari, who survived an lbw review on 25, steadied the ship with a stand of 88 in 17.3 overs.
But when Stanikzai departed in the 28th, Afghanistan suffered a collapse that saw them lose eight wickets for 104 runs.
Stanikzai, with five fours and a maximum, became Rangana Herath’s only victim for 54 off 57 balls, picking out long-on, and Shenwari slapped Thisara to mid-on for 38.
Mohammad Nabi and Mirwais Ashraf contributed 21 and 28 respectively, the latter adding 46 with Afsar Zazi.
Lasith Malinga and Mathews, with three wickets each, stopped Afghanistan in their tracks and prevented them from posting a total above 250.
That looked an impressive score when Sri Lanka made a terrible start to their chase, Lahiru Thirimanne departing lbw to Dawlat Zadran first ball.
Tillakaratne Dilshan departed for a duck in the next, edging Shapoor Zadran behind, before Hamid Hassan bowled Kumar Sangakkara and celebrated with an inelegant cartwheel.
When Dimuth Karunaratne edged Hassan, sporting the Afghanistan flag both on a headband and painted on his cheeks, to slip, a shock appeared to be on the cards.
Jayawardene and Mathews used all their experience, though, getting their side back on track.
There was still plenty to do when the latter was run out in the 41st over and the former followed in the next, edging the pacy Hassan to slip two balls after completing his 19th one-day international ton.
With 58 runs still required, Thisara chanced his arm and denied Afghanistan a huge scalp with six fours and a maximum, helping take 22 runs off the 46th and 47th overs.