After a career-best 8-41 to help dismiss New Zealand for 90, Shah grabbed 6-143 as the Black Caps followed on and were all out for 312 after tea on the fourth day.
Shah equalled the Pakistan record for wickets in a Test with fast bowler Imran Khan, who achieved his feat in 1982 against Sri Lanka in Lahore.
"I haven't bowled as well as this, especially with the pitch offering turn and bounce like it did," Shah said.
"The attempt was to put the disappointment of the first test behind and compete better. We just needed to keep getting wickets, and thanks God that happened."
Centuries by Haris Sohail and Babar Azam put Pakistan in command after making 418-5 declared.
Shah then went to work. He has 22 wickets in the series, and needs five more to reach 200 in his career. They should come in Abu Dhabi, where the teams return for the third test and series decider from Monday.
New Zealand won the first test there by four runs.
"Yasir's spell was the best that I have ever seen in my years of test cricket," Pakistan skipper Sarfraz Ahmed said.
"The responsibility was first with the batsmen to make some runs, and they delivered."
"We batted better in the second innings, but that session yesterday when Yasir put us under tremendous pressure and put the ball in the right areas (did us in)," New Zealand captain Kane Williamson said.
"He is an exceptional bowler, and it's important we learn some lessons quickly because we will face all the bowlers again (in the third test)."
Forced to follow on, New Zealand resumed on 131-2 and Taylor and Latham were out in the first session.
Latham was contentiously adjudged caught behind off Hasan Ali soon after completing his half-century. Umpire Paul Reiffel referred to third umpire Ian Gould to confirm. Latham played a defensive shot close to his front pad, and as the ball passed the bat the replay technology spiked.
However, Latham walked off the field in disbelief. After lasting for 158 deliveries and hitting four boundaries, his dismissal ended an 80-run, third-wicket stand with Taylor.
Two balls later, Nicholls successfully reviewed an lbw decision against him as video showed Hasan's delivery would have missed the leg stump.
Taylor completed his half-century off 54 balls when he drove Hasan through the point boundary off the first ball of the day.
But Taylor went on the defense for a while before he played a reckless sweep, half an hour before lunch, and top-edged offspinner Bilal Asif to deep backward square leg. Taylor's innings featured seven fours and a six and came off 128 balls.
New Zealand reached 222-4 at lunch.
Shah then trapped BJ Watling on 27 off the second new ball after lunch.
Hasan returned to accept the wicket of Colin de Grandhomme for the third time in the series. De Grandhomme went for an unnecessary pull shot and played onto the fast bowler on 14.
Ish Sodhi also gave his wicket away when he tried to sweep Shah, missed the line of the ball and was clean bowled for 4.
Nicholls was undone four overs after tea by Hasan's sharp delivery which nipped back into the left-hander to knock back the off stump.
Shah wrapped up the innings soon after by claiming the wickets of Neil Wagner and Trent Boult.
Hasan finished the innings with 3-46.