New Zealand needed just 36 runs in the last session with five wickets left to dash Bangladesh's hopes of their first victory over a major Test nation on Tuesday.
The tourists, who reached 281-5 at tea on the final day, were spearheaded by captain Daniel Vettori who was unbeaten on a fighting 69 with Daniel Flynn on 29 as they pursued a daunting 317-run target.
Bangladesh had raised hopes of a historic win at the Divisional Stadium when they removed Aaron Redmond (79) and then Ross Taylor (nine) to restrict the tourists to 212-4 at lunch.
The home team then dismissed Brendon McCullum for two, trapped leg-before by left-arm spinner Abdur Razzak, but Vettori found an able ally in Flynn as they added 65 runs for the unfinished sixth-wicket stand.
Vettori's second half-century of the match included six boundaries from 203 balls so far.
A New Zealand win would nearly double their previous best run chase in a Test away from home after they made 164-4 against Australia at Perth in 1985.
Earlier Redmond and Vettori saw off the first hour without loss until Bangladesh hit back through first-innings hero Shakib Al Hasan.
The left-arm spinner, who set a new Bangladesh best innings record of 7-36, had one turn sharply across Redmond's bat and the ensuing edge was smartly held low by Zunaed Siddiqui at slip.
Redmond hit 10 boundaries during his 237-ball knock and added 40 runs for the third wicket with Vettori.
Bangladesh skipper Mohammad Ashraful took the second new ball after 83 overs and was instantly rewarded when Masharfe Mortaza dismissed Taylor, caught at cover by substitute fielder Mahbubul Alam.
Bangladesh's only win in their previous 53 Tests came against Zimbabwe here three years ago.