It was a tough final day for the tourists.
''Not unlucky, no. We have ourselves to blame," opener Tamim Iqbal said.
True, and New Zealand were good enough to, firstly, get close to that first innings score, then bowl with vim and determination to dismiss an injury-hit Bangladesh for 160.
Once Williamson and Ross Taylor (60 off 77 balls) settled into their 163-run stand for the third wicket it was effectively game over.
Williamson's batting was oustanding en route to his 15th century and third at the Basin, after 102 not out against South Africa in 2012 and 242 not out against Sri Lanka in 2015.
''Coming into the last two sessions and either team could win it," he said. ''That's what test cricket is about.
''When you're two for 30, 200 can be quite a long way away in the last innings. We needed to knuckle down, get a partnership together and get a bit of momentum."
Which they did. Between afternoon tea and drinks, they rattled on 79 in 12 overs to give the game a final tug away from Bangladesh.
Taylor was out to a brilliant catch at gully by Mehedi Hasan just before the end, but he deserved high praise for his support role to his skipper, whose quick feet took him into good positions and shot execution simply purred.
The single most arresting sight of the day, however, was Mushfiqur Rahim, Bangladesh's plucky and respected captain, lying on the crease, an ambulance beside the stumps after taking a blow on the back of his helmet from a Tim Southee short ball.
He seemed okay tonight after a trip to hospital, but Mushfiqur showed considerable pluck afer being peppered by short-pitched balls from New Zealand.
A shame the first innings double centurymaker Shakib al Hasan didn't follow suit, lamely giving a catch to deep mid on in the second over of the day when he was sorely needed to contribute.
In some respects this will rank among New Zealand's more remarkable test wins.
Williamson indicated there had been little thought given to pulling out further behind to give them more bowling time at Bangladesh. They backed themselves to put some heat on the tourists' batsmen late on day four and it worked.
You're left wondering if the manner of the defeat will play havoc with Bangladesh's psyche ahead of the second test starting in Christchurch on Friday.