Pakistan kept their World Cup hopes alive to end New Zealand's unbeaten record with a six-wicket win at Edgbaston.
New Zealand 237/6 (50 overs): Neesham 97 no, De Grandhomme 64; Afridi 3-11
Pakistan 241/4 (49.1 overs): Babar Azam 101 no, Haris Sohail 68; Williamson 1-39
New Zealand knew victory would secure a fourth successive World Cup semi-final appearance, but the Black Caps were unable to defend their total of 237 for six against revitalised opposition.
Pakistan still had plenty of work to do at the halfway mark of their chase, being 110 for three on a used pitch that was providing significant assistance to spinner Mitchell Santner.
But Babar Azam's unbeaten 101 - the first World Cup century by a Pakistan player other than an opening batsman since 1987 - saw off New Zealand with five balls to spare.
Babar passed 3,000 one-day international runs in the process, during his 68th innings and only slower than South Africa's Hashim Amla in reaching that landmark.
His 127-ball innings, which contained 11 fours, underlined the 24-year-old's huge talent, but New Zealand wicketkeeper Tom Latham was left to reflect on a spilled catch off Santner when Babar had made 38.
It was to prove a decisive drop and the result was never in doubt after that, despite Santner's spin and the early hostility generated by paceman Lockie Ferguson.
The fourth-wicket partnership between Babar and Haris Sohail, who made 68 from 66 balls before being run out in the penultimate over, was played out in front of ecstatic Pakistan supporters, who delighted in taking over Edgbaston for the day.
It was a gritty all-round team performance from Pakistan, who flew out of the blocks with Shaheen Afridi questioning New Zealand's decision to bat in overcast conditions by taking three wickets.
Their win will also raise anxiety levels in the England dressing room, with only one point now separating the two sides in the race for a top-four finish.
Furthermore, while England complete their group fixtures against India and New Zealand, two likely semi-finalists, Pakistan appear to have a kinder conclusion against Afghanistan and Bangladesh.
Mohammad Amir had first-ball success as Martin Guptill dragged on, but it was Shaheen who shone to leave New Zealand in real difficulty at 46 for four.
The out-of-form Colin Munro (12) drove to slip, Ross Taylor (three) was brilliantly caught by gloveman Sarfaraz Ahmed diving to his right, and Latham (one) also edged behind.
Afridi had figures of 7-3-11-3 from his first spell and finished with three for 28 - the most economical spell by a Pakistan bowler at the last five World Cups.
Kane Williamson, so often New Zealand's saviour, dug in, but the Black Caps skipper fell for 41 as leg-spinner Shadab Khan found prodigious turn to give Sarfaraz a third catch.
Jimmy Neesham and Colin De Grandhomme repaired the early damage with a sixth-wicket partnership of 132 as New Zealand showed their renowned battling qualities.
De Grandhomme was eventually run out for 64 and Neesham compiled an ODI best of 97 not out to set Pakistan what looked like a challenging target.
But New Zealand's wait to book that last-four spot must extend into their final two games against Australia and England.
Pakistan hero Babar Azam admitted that not winning a one-day international for his country had been preying on his mind.
Babar masterminded a crucial six-wicket World Cup win over New Zealand at Edgbaston with his 10th ODI hundred, his unbeaten 101 seeing Pakistan home with five balls to spare.
The win moves Pakistan to within one point of fourth-placed England in the race for a semi-final spot and piles the pressure on Eoin Morgan's men ahead of their Edgbaston clash against India on Sunday.
Pakistan were 110 for three in pursuit of their victory target of 238 but Babar, who has been criticised in the past for failing to get his side across the line, and Haris Sohail shared a decisive fourth-wicket partnership of 126 in 24 overs.
"It was in my mind that I'm not finishing these matches," said Babar, 24, who during his 68th ODI innings became the second-fastest player to reach 3,000 runs - with only South Africa's Hashim Amla getting there quicker.
"When me and Haris were batting we had a plan to carry on the innings, and we have done that. It was a difficult pitch to bat on as it was spinning a lot.
"(Mohammad) Hafeez and I had a plan before to see off the spinners' overs and attack the fast bowlers."
Pakistan had collected only three points from their opening five games, with the only win in that sequence coming against England.
But back-to-back wins over South Africa and New Zealand have provided Pakistan with momentum ahead of closing games against Afghanistan and Bangladesh.
Curiously, their run of results and record after seven games is identical to the Pakistan side that Imran Khan led to World Cup glory in 1992.
"Everybody contributed a lot and we are very focused on this," said Babar.
"We are confident of taking it match by match, and hopefully we will qualify."
New Zealand need to win one of their final two games to make a fourth successive World Cup semi-final appearance.
Jimmy Neesham made a career-best 97 not out in New Zealand's 237 for six and said confidence would not be dented by a first defeat in the competition.
"I think you'd be pretty naive to expect to go through the whole tournament unbeaten," Neesham said.
"There's too many quality teams going around to expect to win every game. We prepared for a tournament where we'd probably lose one or two games.
"But for us, it's all about making it to the semi-finals, and you're only two good games away from lifting the trophy."
New Zealand's next outing is against great rivals Australia at Lord's on Saturday before a Durham finale with England.
Neesham added: "For us, nothing changes. The mood in the dressing room is good and we'll prepare for the next game the same way we've prepared for the last six.
"We're not the type of team that takes losses really hard. We'll talk about how that game went, and then we'll pretty much park it and hit our scouting pretty fresh."