Afghanistan opener Ibrahim Zadran's record 162 -- the highest individual score for the Afghans -- went in vain after he steered the tourists to 313-8 in Pallekele. Sri Lanka were in trouble at 249-6, but the left-handed pair of Asalanka and Dunith Wellalage put on an unbeaten stand of 65 to steer the team home with two balls to spare. The island nation kept up their hopes of earning a direct entry into next year's ODI World Cup in India with crucial 10 Super League points from the win. Asalanka, battling cramps during the later half of his 72-ball knock, hit the winning six as the home crowd erupted in joy with the highest-ever chase at the venue. Wellalage, 19, also kept his calm in his 31 off 21 balls as he smashed Gulbadin Naib for three fours in the 49th over to take some pressure off Asalanka, who refused many doubles as he hopped around. Afghan spin wizard Rashid Khan returned figures of 4-37. Sri Lanka had started strongly with openers Pathum Nissanka (35) and Kusal Mendis (67) putting on 101 runs. Dinesh Chandimal and skipper Dasun Shanaka also made useful contributions of 33 and 43. Asalanka then put on a 79-run stand with Shanaka as the duo mixed the right dose of caution and aggression. Rashid broke through to get Shanaka bowled with a googly that rattled the stumps and soon struck his fourth blow as Wanindu Hasaranga walked back caught behind for two before Asalanka and Wellalage took over. Ibrahim, 20, stood out for Afghanistan, who had earned their automatic qualification for the World Cup with the previous rained off match, with 278 runs including a match-winning 106 in the opener. He put on 154 runs with the left-handed Najibullah Zadran, who made 77, to rebuild the Afghan innings after three early wickets and put Sri Lanka on the back foot. The effort was Afghanistan's best fourth-wicket partnership, breaking a 2013 record of 144 between Nawroz Mangal and Samiullah Shinwari against Scotland. It was Ibrahim's third century in just his eighth ODI and surpassed Afghanistan's previous top score of 131 not out by Mohammad Shahzad. Ibrahim stood firm to take on the bowlers as he surpassed his previous best of an unbeaten 121 before departing on the final ball of the innings. He hit 15 fours and four sixes in his 138-ball knock.