Shaheen Shah Afridi recorded his career best bowling while opener Fakhar Zaman hit a half century to help Pakistan to a series-levelling victory.
Shaheen's 4-38 kept New Zealand down to 209-9 in their 50 overs before Zaman returned to form with a run-a-ball 88 for his seventh fifty to guide Pakistan to their target for the loss of four wickets in 40.3 overs.
Veteran batsman Ross Taylor top-scored for New Zealand with a laborious 120-ball 86 not out and added 75 for the fifth wicket with Henry Nicholls, who made a gruelling 33 off 63 balls.
With the win Pakistan broke a four-year losing streak of 12 consecutive one-day internationals against the Black Caps, starting with a 3-2 defeat in the UAE in 2014.
New Zealand had also beaten Pakistan 2-0 (in New Zealand 2015), 2-0 (in New Zealand in 2016), 5-0 (in New Zealand in January this year) and in the first match of the current series by 47 runs in Abu Dhabi on Wednesday.
The win also sets up an intriguing final match in Dubai on Sunday.
"We wanted to stage a comeback and the team did well to do that," said Pakistan captain Sarfraz Ahmed. "We kept them to a low total courtesy of Shaheen and then Fakhar and Babar batted so well."
New Zealand skipper Kane Williamson admitted his team did not put a defendable total.
"A bit of scrapping that got us a total," he said. "It wasn't enough on that surface. We were outplayed."
Zaman, who had a poor 57 runs in the last six one-day internationals, punished the New Zealand bowlers with 11 boundaries and had given Pakistan a rapid 54 run start with Imam.
Undeterred by Imam's injury, Zaman added a quick 101 for the second wicket with Babar Azam who made a 50-ball 46 before both fell in the same Ferguson over.
Ferguson, who finished with 3-60, then had another lucky wicket of Shoaib Malik for ten when a ferocious pull deflected off Nicoll's shoulder and was caught at mid-on by Ish Sodhi.
Sarfraz fell for 13 but Mohammad Hafeez hit the winning boundary to finish with 27 not out.
Earlier, the Taylor-Nicholls stand lifted New Zealand after Shaheen once again rocked the top order following his 4-46 in the first match.
Shaheen dismissed destructive opener Colin Munro in the second over of the innings, holing out to a tough catch by Hafeez.
In his next over he deflected a straight drive to run out Kane Williamson (one) at the non-striker's end.
In his second spell, Shaheen yorked Tom Latham for one while Hafeez bowled George Worker for 28 to leave New Zealand struggling at 73-4.
Taylor, who made 80 in the first game, held one end intact and together with Nicholls ensured the innings did not finish under 200.
Nicholls was finally bowled in the 38th over by Hasan Ali who finished with 2-59.
Taylor hit three boundaries and a six for his 43rd half century in one-day internationals.