Williamson and Ross Taylor, determined not to run out of time, batted at more than 6.0 an over in their 163-run third wicket partnership with New Zealand chasing down a 217-run target.
The New Zealand skipper finished unbeaten on 104 with Taylor out for 60 and Henry Nicholls not out four.
Bangladesh were in command for nearly four days, until their second innings lasted less than 58 overs to end at 160-9 and captain Mushfiqur Rahim in hospital after being felled by a Tim Southee bouncer.
The previous mark was set more than 120 years ago, when Australia scored 586 against England at the Sydney cricket ground in 1894.
More From This Section
New Zealand made a shaky start to their run chase with first innings centurion Tom Latham out for 16 and fellow opener Jeet Raval for 13, both removed by off-spinner Mehedi Hasan in the space of eight balls.
But Williamson and Taylor were unruffled on a warm Wellington afternoon that was a far cry from the blustery first day when Bangladesh batted positively on a green wicket.
Bangladesh resumed the final day at 66-3 and were in early trouble when Shakib Al Hasan, whose 217 in the first innings is a record high score for a Bangladesh batsman, lasted only five balls before going for a duck.
Mominul Haque, who has two centuries to his name in five previous innings against New Zealand, was removed this time for 23.
At 96-5, Sabbir Rahman and Mushfiqur added 18 runs in 16 overs in the face of a torrid attack from the New Zealand pace trio of Southee, Trent Boult and Neil Wagner.
He lay prone on the wicket, attended by medical staff from both teams until an ambulance drove on to the field and took him to hospital. He was later given the all-clear.
Opener Imrul Kayes, who was stretchered off and taken to hospital late on the fourth day with a hip injury, hobbled to the crease at the fall of the seventh wicket.
Unable to run, he relied on boundaries to be 36 not out when the innings ended.
The second Test starts in Christchurch Friday.