It turned into a thrilling finish. But Mohammad Saifuddin bowled an inexplicable bouncer wide to Lockie Ferguson in what should have been the final ball of the 47th over, followed by another wide down leg side, and Ferguson then squeezed a boundary to third man to level the scores.
Mitchell Santner delivered the final blow in the next over.
Read Niall Anderson's match report: Black Caps survive major Bangladesh scare to go top on World Cup ladder
'Got across the line'
Captain Kane Williamson reckoned it was "nice to get across the line".
"The first half was outstanding, the fielding was excellent," he said.
"It was not the most clinical effort with the bat...a few soft dismissals but a good experience to have in this tournament.
"Santner was outstanding with the ball, we were expecting a little more pace from the surface but the guys adjusted to build pressure."
Close call
Technology revealed a brilliant piece of umpiring from Aussie Paul Reiffel as Bangladesh threatened to pull off a miraculous win.
With New Zealand needing 23 runs from 33 balls, and only three wickets left, Mohammad Saifuddin looked for all the world to have trapped Mitchell Santner lbw.
Bangladesh appeared bewildered by the not out call from Reiffel, and they were out of reviews.
But replays showed that the ball had officially pitched outside leg stump by the smallest of whiskers, even though a significant part of it was in line with the stumps.
New Zealand had a review left and would surely have used it to rescue Santner if needed.
'Full-on crisis'
Proteas in "full-on crisis"…that was the reaction by South Africa's Supersport, after the six wicket loss to India in cricket's World Cup.
"South Africa face a difficult week of soul-searching before they meet the West Indies at the same venue next week," it reported, after a third successive defeat by the notorious World Cup chokers.
India on the board
Indian captain Virat Kohli said "my hands were buzzing" after he caught Quinton de Kock off Jasprit Bumrah's bowling.
"That's how quick he's bowling," said the great Indian captain.
South African captain Faf du Plessis was all class as his team just about plummeted out of World Cup contention after three games.
"India were magnificent on a difficult pitch," he said.
The gifs that keep giving
We're all giving it the Guppy after that win.