Number ten batsman Naseem Shah hit a boundary off the penultimate delivery to give Pakistan a dramatic one-wicket win over a luckless Afghanistan in the second ODI at Hambantota on Thursday.
The 20-year-old miscued a boundary off fast bowler Fazalhaq Farooqi and ran jubilantly towards the dressing room as Pakistan scored 11 off the final over to finish with 302-9 in 49.5 overs.
The victory gave Pakistan an unassailable 2-0 lead in the three-match series with the last game in Colombo on Saturday.
Pakistan's late surge overshadowed Afghanistan opener Rahmanullah Gurbaz's career-best run-a-ball 151 that lifted his team to 300-5 in their 50 overs.
The final two overs of Pakistan's chase were full of drama.
Shadab Khan hit Abdul Rahman for a four and a six off the last two balls of the 49th over.
Farooqi ran out Shadab at the non-striker's end at the start of the last over with a Mankad dismissal.
Naseem came in and hit the first ball he faced for four and did the same off the fifth delivery to win the game.
Naseem had hit the same bowler for two last over sixes to give Pakistan victory by one wicket in the Asia Cup Twenty20 game in Sharjah last year.
Shadab, whose 35-ball 48 contained three fours and a six, revived Pakistan's chase in the final overs after his team fell to 258-7.
Opener Imam-ul-Haq's 105-ball 91 with four fours set the platform.
Haq shared a robust 52-run stand with fellow opener Fakhar Zaman (30) and another of 118 runs for the second wicket with skipper Babar Azam who made a 66-ball 53 with six boundaries.
From 170-1 in the 31st over, Afghanistan hit back by grabbing five wickets in 41 runs to push Pakistan to 211-6.
Farooqi had Azam caught off a miscued flick. Spinner Mohammad Nabi had Agha Salman (14) and Usama Mir (nought) in the same over. Mohammad Rizwan was run out for two as Pakistan slid.
Fellow spinner Mujeeb Ur Rahman dismissed Haq in the next over to leave Pakistan in a spot of bother before Afghanistan ran out of luck.
Azam praised his players.
"All credit to the boys," said Azam whose team will jump to number one in ODI rankings if they win the final match. "We knew we could chase 80 or 90 in the last 10 overs and praise for Naseem who comes up in crunch situations."
Afghanistan skipper Hashmatullah Shahidi admitted the defeat was painful.
"It is hurting because we had enough runs but at the last moment they took the game away from us," said Shahid, blaming the penultimate over for the swing of fate.
"The...49th over there were some easy balls to the batsman and they smashed it."
Earlier, the 21-year-old Gurbaz shared an opening stand of 227 with Ibrahim Zadran, who scored a 101-ball 80, after Afghanistan won the toss and batted.
Gurbaz hit 14 fours and three sixes against a world-class attack that had reduced Afghanistan to 59 all out in the first game on Tuesday.
Gurbaz's previous best was 145 against Bangladesh in Chattogram last month.
Zadran also hit out brilliantly with six boundaries and two sixes.
Spinner Usama Mir broke the opening stand in the 40th over when he had Zadran caught at long off. Pacer Shaheen Shah Afridi dismissed Gurbaz caught behind in the 45th over.
Shaheen also had Rashid out for two to finish with 2-58.
Nabi made a run-a-ball 29 before he was caught off Naseem Shah as Afghanistan piled up 73 runs in the last ten overs.
Fast bowler Haris Rauf, who picked up a career-best 5-18 in the first match, went for 48 in seven overs without success.