Azhar Ali was unbeaten on 62 at the close with Asad Shafiq on 26. Pakistan still trail by 135 runs with seven wickets intact.
BJ Watling scored an unbeaten 77 to carry New Zealand to 274 after resuming at 229-7. Off-spinner Bilal Asif took 5-65 while lag-spinner Yasir Shah finished with 3-75.
Azhar Ali and Haris Sohail shared an unbroken partnership of 64 for the third wicket as Pakistan recovered from the early loss of both openers to reach 81-2 at tea.
This is the deciding in a fascinating series which currently stands 1-1.
Boult had out-of-form Mohammad Hafeez caught low down at second slip by Tim Southee for a fourth-ball duck in his first over right before the lunch interval.
In the fourth full over after the break, Imam took his eye off a Trent bouncer and was hit on the back of the helmet. Next ball, he edged to Southee at third slip and was on his way for just nine.
It was Watling, with an unbeaten 77, who carried New Zealand´s overnight total from 229-7 and added an invaluable 45 runs over the last three wickets to frustrate Pakistan.
During his five-and-a-half-hour knock Watling, when on 66, passed 3,000 runs in his 56th Test.
He is the 14th New Zealand batsman to score 3,000 or more runs, joining a list topped by Stephen Fleming who scored 7,172 in 111 Tests.
Watling, dropped on nine by Imam off Bilal Asif on Monday, and debutant Will Somerville extended their eighth wicket partnership to 45 before Bilal Asif took all three final wickets to finish with 5-65, his second five wicket haul in five Tests.
Watling, playing his 56th Test, reached his 16th Test half-century with a boundary off medium pacer Hasan Ali after facing 199 balls.
In all he batted for five hours and 32 minutes, hitting four boundaries.
Asif bowled Somerville without any addition to his overnight score of 12, then had Ajaz Patel caught for six before bowling Boult for one.
Leg-spinner Yasir Shah, in his 33rd Test, failed to add to his three wickets on Monday, leaving him two short of becoming the fastest man to reach 200 Test scalps.
The current record has stood for 82 years after Australia’s Clarrie Grimmett reached 200 wickets in 36 Tests in 1936.