Williamson miscued spinner Abdul Razzak, ending his third straight big knock, after scoring 114 and 74 in the first Test.
With a lead of five runs, Anderson was finally out, driving straight to Gazi at extra cover to give Al-Amin Hossain his first Test wicket on debut.
Anderson made 116 off 173 balls, with 13 boundaries and two sixes.
He took 10 deliveries to get off the mark and had no problems playing left-arm spinners Shakib and Razzak or medium-fast bowler Rubel Hossain, against whom he hit five fours. He even raced through the 90s, with no sign of any nerves.
At 287-6, Bangladesh would have thought they could limit New Zealand’s lead and perhaps bat before the end of the day, but the Kiwi tail patiently dug in.
Shakib completed his 10th five-wicket haul when he dismissed Doug Bracewell on 17, which brought tea, but he could not bag another wicket afterwards.
Fast bowler Neil Wagner’s wicket was the only one to fall in the last session, as Bangladesh tired in the field.
Wicketkeeper Watling and spinner Sodhi, playing his second Test, combined for an unbeaten 84 for the ninth wicket. Watling was the more circumspect of the pair, as Sodhi galloped to his 50 off 59 balls.