The fiery all-rounder dismissed Kane Williamson for 27 and Brendon McCullum for a golden duck before a defiant sixth-wicket partnership of 107 between Corey Anderson and BJ Watling gave New Zealand hope of salvaging a draw.
But Mark Wood removed Watling for 59, Anderson was lbw to Joe Root for 67 and England quickly got rid of Mark Craig and Tim Southee.
Last-wicket-pair Matt Henry and Trent Boult survived for eight overs amid mounting tension before the latter was brilliantly caught at third man by a diving Moeen Ali off Stuart Broad as the Kiwis were bowled out for 220.
New Zealand, chasing 345 for victory, collapsed to 12 for three before lunch but Williamson and Watling lifted them to 61 for three.
Stokes, who struck the fastest test century at the home of cricket on Sunday, had the obdurate Williamson caught by Root in the slips for 27 before bowling captain McCullum with a venomous delivery that cut back sharply.
Anderson survived the hat-trick ball and immediately went on the attack, hitting Stokes for two fours and a six, and he continued to play positively alongside the more circumspect Watling as New Zealand took tea on 134 for five.
Wood broke the partnership when Watling gloved a fast straight delivery to wicketkeeper Jos Buttler and Anderson was trapped by Root.
Stokes returned to bowl Craig for four with a rapid full-pitched delivery and Southee was caught and bowled by Moeen for 20.
James Anderson and Broad had ripped out the top order to give England the scent of victory before lunch.
Martin Guptill edged Anderson’s second ball of the innings to Gary Ballance at third slip.
Broad trapped Tom Latham lbw with his first delivery to reduce the touring side to nought for two and he also dismissed Ross Taylor in the same manner as New Zealand slumped to 12 for three.
Earlier, Kiwi left-armer Boult picked up the last four wickets in under an hour as England were bowled out for 478.
The hosts resumed on 429 for six and Boult had captain Alastair Cook caught by wicketkeeper Latham for 162 before bowling Broad for 10.
Moeen was lbw for 43 and Anderson was bowled for nought to give Boult figures of five for 85 in the innings and nine wickets in the match. – Reuters