Pakistan now need to win their final match against Bangladesh on Friday and hope other results go their way to advance to the semi-finals
All-rounder Imad Wasim's unbeaten 49 guided Pakistan to a thrilling three-wicket victory over minnows Afghanistan in Leeds on Saturday, maintaining their hopes of reaching the World Cup semi-finals.
Chasing a target of 228, Pakistan lost opener Fakhar Zaman for a duck on the second ball of the innings when he was trapped leg-before by off-spinner Mujeeb Ur Rahman.
Babar Azam, who scored his maiden World Cup century in Pakistan's win over New Zealand earlier this week, combined with Imam-ul-Haq to stabilise the innings with a steady 72-run partnership.
Off-spinner Mohammad Nabi removed the pair to expose the middle order, before Mohammad Hafeez and Haris Sohail fell cheaply to leave Pakistan reeling at 142-5.
Captain Sarfaraz Ahmed (18) and Shadab Khan (11) were run-out to set up an intense finale but Wasim and Wahab Riaz (15) ensured there were no further hiccups as they chased down the target with two balls to spare.
Pakistan now need to win their final match against Bangladesh on Friday and hope other results go their way to advance to the semi-finals.
Earlier, Pakistan fast bowler Shaheen Afridi claimed four wickets to restrict Afghanistan to a modest 227 for nine from 50 overs on a flat batting track at Headingley.
The game was marred by a clash between the supporters of both teams in the stands, with ESPNcricinfo reporting that at least two fans were evicted from the match.
Videos shared on social media also showed fans fighting outside the venue, with the International Cricket Council saying it will take action against "any anti-social behaviour".
AFGHANISTAN INNINGS R B
Rahmat c Babar b Imad 35 43
Naib c Sarfaraz b Afridi 15 12
Shahidi c Imad b Afridi 0 1
Alikhil c Hafeez b Imad 24 66
Afghan b Shadab 42 35
Nabi c Amir b Riaz 16 33
Najibullah b Afridi 42 54
Shinwari not out 19 32
Rashid c Fakhar b Afridi 8 12
Hamid b Riaz 1 3
Mujeeb not out 7 9
Extras (lb 8, w 10) 18
Total (50 Overs) 227/9
Fall Of Wickets
1-27 (Naib), 2-27 (Shahidi), 3-57 (Rahmat), 4-121 (Afghan), 5-125 (Alikhil), 6-167 (Nabi), 7-202 (Najibullah), 8-210 (Rashid), 9-219 (Hamid)
Imad 10-0-48-2, Amir 10-1-41-0, Afridi 10-0-47-4, Hafeez 2-0-10-0, Riaz 8-0-29-2, Shadab 10-0-44-1
PAKISTAN INNINGS R B
Fakhar lbw b Mujeeb 0 2
Imam st Alikhil b Nabi 36 51
Babar b Nabi 45 51
Hafeez c Shahidi b Mujeeb 19 35
Haris lbw b Rashid 27 57
Sarfaraz run out (Najibullah) 18 22
Imad not out 49 54
Shadab run out (Naib) 11 17
Riaz not out 15 9
Extras (b 1, lb 4, w 5) 10
Total (49.4 Overs) 230/7
Fall Of Wickets
1-0 (Fakhar), 2-72 (Imam), 3-81 (Babar), 4-121 (Hafeez), 5-142 (Haris), 6-156 (Sarfaraz), 7-206 (Shadab)
Mujeeb 10-1-34-2, Hamid 2-0-13-0, Naib 9.4-0-73-0, Nabi 10-0-23-2, Rashid 10-0-50-1, Shinwari 8-0-32-0
Pakistan won by three wickets
MoM: Imad Wasim