Sri Lanka recovered from a dramatic batting collapse to knock over Afghanistan for 152 and seal a 34-run win for its first victory at the World Cup, on Tuesday.

The Sri Lankans imploded from 144/1 to 201 all out in an innings delayed by nearly three hours because of rain at Sophia Gardens in the Welsh capital.

Chasing a revised target of 187 from a maximum 21 overs, Afghanistan slumped from 34/0 to 57/5 then battled back through a 64-run stand between Gulbadin Naib (23) and Najibullah Zadran (43).

Sri Lanka again responded and took the final five wickets for 31 runs, with recalled seamer Nuwan Pradeep getting 4/31.

The 1996 World Cup winners had lost their opening group game to New Zealand by 10 wickets. Afghanistan have two defeats from two matches, after a loss to Australia on Saturday.

The error-strewn match in Cardiff featured 52 extras—Sri Lanka’s 35 was the second-highest scorer in the scorecard—to strengthen the feeling this was a contest between the two teams likely fighting to avoid last place in the 10-team group.

The Afghans’ only win at a World Cup remains the one over Scotland in 2015 but they will feel this match slipped from their grasp, especially when Sri Lanka were reeling at 159/6 after three wickets in one over from Mohammad Nabi.

Sri Lanka, who made the fastest 10-over start to the tournament by racing to 79/0, lost its last nine wickets for 57 runs in 15.4 overs.