Debutant spinner Ajaz Patel claimed five wickets in the second innings, as New Zealand beat Pakistan by four runs on a dramatic fourth day of the opening cricket test in Abu Dhabi.
Pakistan resumed the day on 37/0, needing only 139 runs for a victory to take a 1-0 lead in the three-match series, but suffered two separate batting collapses that resulted in a tense finish at the Sheikh Zayed Stadium.
The hosts were eventually dismissed for 171 in 58.4 overs, as the visitors wrapped up the fifth-smallest win by runs in test history.
"We knew the surface wasn't an easy one," New Zealand skipper Kane Williamson said. "There was turn from day one and all the spinners bowled well.
"It's a great advertisement for test cricket. In the end, it came down to the wire.
"We'll sit down, and review our performance and the things to improve upon. The attitude, certainly today and throughout the game, was brilliant."
Azhar Ali (65), who stitched together an 82-run stand with Asad Shafiq (45) to keep Pakistan's hopes alive, was the last batsman to fall, trapped in front of the wicket by Patel, who finished with 5/59.
"It's a dream come true," left-armer Patel said. "We know Pakistan have got good players of spin, but we kept chipping in there."
Earlier, Patel dismissed opener Imam-ul-Haq leg-before, and spin partner Ish Sodhi struck twice to remove Mohammad Hafeez and Haris Sohail, as Pakistan lost three batsmen in eight balls to find themselves in trouble at 48/3.
Shafiq edged pace bowler Neil Wagner to wicketkeeper BJ Watling before lunch and Babar Azam was run out after the break. Pakistan skipper Sarfraz Ahmed was then caught behind off Patel for three, with his team down 154/6 and needing 22 runs to win.
Bilal Asif was bowled for a duck, as he attempted to slog Patel and Wagner had Yasir Shah caught at slip. Hasan Ali was the next to go, offering a simple catch to substitute fielder Tim Southee, off Patel.
Azhar played more cautiously, as the wickets continued to tumble, but despite the 33-year-old's battling effort, Pakistan could not avoid defeat.
The second test will be played in Dubai from November 24-28, before the teams return to Abu Dhabi for the final test from December 3-7.