Bangladesh faced a 481-run deficit after New Zealand amassed 715-6 in reply to its first innings of 234. Undaunted, Soumya compiled 149 — his maiden Test century — and Mahmadullah 146 in a 235-run partnership which delayed New Zealand's push for victory for much of the fourth day.
Both players achieved their highest Test scores — Soumya eclipsing his previous best of 86 and Mahmudullah, with his fourth Test century, beating his previous highest of 136.
Together they batted through all of the first session and most of the second. But Trent Boult excelled with the second new ball, breaking the stubborn stand between Soumya and Mahmudullah when Bangladesh was 361, still 121 runs behind.
Mahmudullah battled on but his support quickly dwindled as Boult claimed 5-123 — his eighth five-wicket bag in Tests. Bangladesh was eventually all out for 429 with the last wicket falling early in the final session.
"It feels great," New Zealand captain Kane Williamson said. "We knew coming here today it was going to be a big push with the ball.
"We knew that the surface was not going to offer a huge amount. We also knew that they have a lot of quality in their batting lineup and they did show that today.
"But it was great that we were able to stick together for a long period of time, break that partnership which was brilliant for them and then take the rest of the wickets in that middle session."
Bangladesh resumed at 174-4 Sunday with the partnership between Soumya and Mahmudullah in its infancy, then worth 48 runs. Though the pitch at Seddon Park was offering little to the bowlers and there had already been four centuries in the match, New Zealand must have hoped that it could quickly wrap up the Bangladesh innings and secure victory.
New Zealand has risen to No. 2 in world rankings, recently leap-frogging South Africa and it hoped to show itself deserving of that ranking in only its third Test at home this summer.
But Bangladesh, which came into the match after an unprecedented run of three consecutive Test wins, was not prepared to capitulate.
Soumya and Mahmudullah batted through all of the first session, weathering a hail of short-pitched deliveries as New Zealand tried to bounce the batsmen out.
Soumya had his maiden century before lunch, achieving the milestone from only 94 balls to match Tamim Iqbal's record for the fasTest century by a Bangladesh player in Tests.
Mahmudullah reached his century after lunch from a relatively sedate 183 balls, though he hit 16 fours and a six.
New Zealand's bowling approach changed with the arrival of the second new ball; Boult and Tim Southee were able to bowl fuller and extract a little swing.
Boult bowled Soumya with a ball which nipped back late and quickly added the wickets of Liton Das and Abu Jayed to pitch Bangladesh towards defeat. Mahmudullah battled on and was the second to last wicket to fall, caught by Boult off Southee.
"The wicket was really good to bat on and I think probably we missed our opportunities in the first innings," Mahmudullah said. "Having 120-odd for one wicket we then collapsed and I think that was the main opportunity that we missed."
The match was punctuated by great batting performances: Tamim's 126 in the Bangladesh first innings, Williamson's unbeaten 200 for New Zealand which followed Tom Latham's 161 and Jeet Raval's 132, his maiden century.