Bangladesh, seeking a first win over New Zealand, ended the penultimate day on Sunday with a 122-run lead on 66 for three but possibly only six wickets in hand after opener Imrul Kayes retired hurt.
Although a draw remains the most likely outcome, both sides have the chance to force the issue should Bangladesh offer a sporting final-day declaration on a pitch still full of runs.
A short-pitched barrage by the Bangladesh quicks and poor shot selection against part-time Mahmudullah stopped the New Zealand first innings at 539.
The tourists built on the 56-run lead to be 66 for three at stumps in their second innings with Mominul Haque not out on 10.
Tamim Iqbal made 25 and Imrul was stretchered off after injuring his left hip when diving for a single having made 24.
After New Zealand resumed the fourth day at 292 for three, opener Latham batted on to 177 to ensure the follow-on mark was comfortably passed.
BJ Watling (49) and Mitchell Santner (73) reduced the deficit to less than 100, with Santner and Trent Boult (4 not out) frustrating Bangladesh with a 35-run partnership for the final wicket.
Santner lofted Shakib Al Hasan over the long-on boundary for six, his third of the innings, to overtake his previous best 71 against India at Kanpur four months ago.
- Bouncer barrage -
Bangladesh tried to rattle the New Zealand tail with short balls. Santner took one fierce blow to the head from Taskin Ahmed and Neil Wagner was hit three times by Kamrul Islam drawing blood from his chin.
Wagner, New Zealand's short-ball specialist, passed a concussion test and replaced his helmet after the third blow only to be dismissed two balls later for 18.
Despite the pace barrage it was part-time spinner Mahmudullah who broke through the Watling-Santner partnership.
The pair put on 73 after Latham's dismissal to reach 471 for six when Mahmudullah came into the attack and the innings was all over 68 runs later.
Mahmudullah's first ball was short-pitched and well off-line which Watling went to smack to the boundary only to scoop it into the hands of wicketkeeper Imrul down the leg side.
With his fifth ball, Mahmudullah had Tim Southee trapped in front for one.
Wagner was caught behind trying to hook his way out of Kamrul's bouncer onslaught to give Imrul his fifth catch, a Test record for a substitute wicketkeeper.
Last man out Santer was the fourth New Zealander and ninth player in the match to pass 50.
Latham had been a model of patience for most of his 463 minutes at the crease until he offered a chance on 158 and was dropped by Mehedi Hasan.
But he could not escape the umpire's finger when trapped in front for 177 by Shakib Al Hasan.
BJ Watlingmahmudullahmitchell santnerNew Zealand vs Bangladesh 2016-17shakib al hasanTim Southeetom lathamTrent BoultWellington Test
First Published: January 15, 2017, 12:36 PM IST