Neil Wagner grabbed three wickets to wrap up the tail after Tim Southee, Matt Henry, Colin de Grandhomme and spinner Mitchell Santner had all claimed victims in the final session as the visitors slumped from 199-3 to 230 all out.
Pakistan had not lost a test series since they were beaten 2-0 by Sri Lanka in August 2014, winning five and drawing two, which included one tied series in England this year that gave them the top test ranking before India supplanted them.