Pakistan kept their hopes of a World Cup semi-final place alive as they moved to within a point of England with a six-wicket victory over New Zealand.
Babar Azam's 101 saw Pakistan home in front of a partisan crowd at Edgbaston after Shaheen Afridi had ripped through New Zealand's top order.
Jimmy Neesham's unbeaten 97 had given New Zealand a chance on a slow pitch.
But Pakistan's win with five balls to spare leaves hosts and pre-tournament favourites England in more danger.
Only wins against New Zealand and India in their final two group games will be enough to guarantee England a semi-final place.
Just last week the top four places looked set but qualification could now go to the wire.
New Zealand would have joined Australia in confirming a top-four finish with a win but now they too have work to do after a first defeat of the tournament.
Pakistan came into the game still hoping to emulate their 1992 victory, when they came through to lift the World Cup in Melbourne despite winning only one of their opening five group games - a miserable start they have matched this time around.
Then, three wins from their final three games propelled them into the semi-finals, and a repeat this year could well do the same.
Thrashed by rivals India, crushed by West Indies and sunk by a collapse against Australia, Pakistan looked to be out of contention.
But wins against Afghanistan at Headingley on Saturday and Bangladesh at Lord's on 5 July could see them into the last four - this victory lifted their chances from 20% to 36%, according to statisticians Opta.
Despite some dangerous if inconsistent bowling from New Zealand, Pakistan were always on top chasing a modest 238 to win, batting calmly and keeping the required rate at around a run a ball throughout.
Lockie Ferguson was bowling 94mph bouncers and struck with his second ball, a brutal delivery that found the handle of Imam Ul-Haq's bat, while left-arm spinner Mitchell Santner later had batsmen in real trouble during a brilliant spell.
But despite beating the bat on numerous occasions, Santner went wicketless, and it was captain Kane Williamson who was the partnership breaker, striking in his first over in 13 ODIs as Mohammad Hafeez holed out to deep midwicket.
That wicket could have been a trigger for a collapse but Babar and Haris Sohail - fresh from a brisk 89 against South Africa - batted near faultlessly in a match-sealing partnership of 126.
Babar brought up his 10th ODI century from 124 balls - his first hundred in a successful chase - to give an already raucous crowd their biggest cheer of the day.
Haris was run out in the penultimate over for 68 but captain Sarfaraz Ahmed hit the first ball of the final over for four to seal a famous win.
Having won the toss for a fifth time in six games, Williamson chose to bat and the number three found himself at the crease after just seven balls as opener Martin Guptill dragged on.
Buoyed by a crowd who generated the most noise of the tournament so far, Pakistan's bowlers were magnificent as they reduced the Black Caps to 83-5 in the 27th over.
Shaheen, 19, was the star performer, swinging the ball with genuine pace across the right-handers to prove a constant threat. As well as taking the key wickets of Colin Munro, Ross Taylor and Tom Latham, he strangled the scoring rate, going for just two runs from 25 deliveries at one stage as New Zealand went 13 overs and more than an hour without a boundary.
New Zealand only scored 20 runs between overs 10 and 20, and any sort of defendable score looked beyond them once Williamson edged the leg-spin of Shadab Khan behind. The skipper had gone 333 runs between being dismissed in this tournament - a new World Cup record.
That brought Colin de Grandhomme to the crease alongside Neesham, and while the big all-rounder played and missed with alarming regularity at the start of his innings, he stuck around long enough to get in.
Once De Grandhomme had survived a very tight run out review, he and Neesham accelerated the scoring rate to at least put a defendable target on the board.
The 132-run partnership eventually ended when De Grandhomme was run out after smart work behind the stumps by Pakistan captain Sarfaraz.
But despite a first defeat of the competition one more win - against either England or Australia - will definitely be enough for New Zealand to qualify.
Source: BBC Sports