Pakistan 230 for 7 (Wasim 49*, Babar 45, Nabi 2-23) beat Afghanistan 227 for 9 (Afghan 42, Najibullah 42, Shaheen 4-47) by three wickets
Leeds: Pakistan survived a scare to beat Afghanistan by three wickets with two balls remaining in a thriller at Headingley that moves Sarfaraz Ahmed's side above England in the race for a World Cup semi-final spot in Leeds on Saturday..
Chasing 228 for victory, Pakistan fell to 81-3 and 156-6 as Afghanistan turned the screw and, with 48 needed from 36 balls, it looked out of Pakistan's hands.
However, a disastrous 46th over by Afghanistan captain Gulbadin Naib was smashed for 18 runs by Imad Wasim to put Pakistan back in control.
Despite Shadab Khan being run out with 22 runs needed for victory, Imad and Wahab Riaz held their nerve, with Wahab striking the first six of the innings to take the rate down to a run a ball.
In an astonishing finish, Imad drove Gulbadin to the boundary to reach an unbeaten 49, tie up victory with two balls remaining and move his side ahead of England in the table.
It makes it more likely that England will need to beat both India on Sunday and New Zealand on Wednesday to reach the last four.
Should Pakistan beat Bangladesh - who are also in contention for the semi-finals - on Friday, it would put further pressure on England.
Afghanistan, meanwhile, are still winless - and just as they did against India, they have come tantalisingly close to a stunning victory.
Earlier, Pakistan fast bowler Shaheen Afridi claimed four wickets to restrict minnows Afghanistan to a modest 227 for nine.
Having won the toss and elected to bat, Afghanistan stumbled early on as they lost captain Gulbadin Naib and Hashmatullah Shahidi in back-to-back deliveries to Afridi, who produced a blistering opening spell with the new ball.
Former skipper Asghar Afghan and Ikram Alikhil built a 64-run stand before Afghan was cleaned up by leg-spinner Shadab Khan for 42.
Wicketkeeper-batsman Alikhil (24) holed out to left-arm spinner Imad Wasim but Najibullah Zadran's scored a patient 54-ball 42 to take the Afghans past the 200-mark.
Afridi, playing only his 18th ODI at the age of 19, returned to remove Zadran and Rashid Khan to finish as pick of the Pakistan bowlers with 4-47.