Wagner took three for 22 in the space of 24 deliveries; Sodhi used his height to get bounce and turn for a good return.
Williamson's injury came after he and Ross Taylor were repairing a poor start, in which openers Hamish Rutherford and Peter Fulton departed softly just before lunch.
In trying to avoid a bouncer from the lively Rubel Hossain, Williamson was struck a solid blow on his grille, just beside his left eye.
He got repairs, and stitches, and returned when captain Brendon McCullum departed, pulling a long hop to deep square leg where Hossain leapt and grabbed a spectacular catch.
The pitch is taking turn, Bangladesh have three spinners and will bowl last. Testing times lie ahead for New Zealand's batsmen.
Taylor, playing his 50th test, worked hard, cutting strongly and driving efficiently. He was beaten a couple of times but it was a day for taking care on a pitch which is ensuring the bowlers' are always in the contest.
+ New Zealand's final tour match, the sole T20 game on November 6, has been switched from Sylhet to the Shere Bangla stadium.
Bangladesh have been given an extension from September 30 to November 30 to have their stadiums in order to host the world T20, from March 16 and April 6 next year.
Bangladesh v New Zealand
Second test (Dhaka)
Second day, stumps
Bangladesh
First innings (overnight 228-5)
T. Iqbal c Williamson b Wagner 95
A. Haque c Williamson b Boult 7
M. Ayub b Wagner 41
M. Haque c Watling b Anderson 47
S. al-Hasan lbw b Sodhi 20
M. Rahim c Fulton b Wagner 18
N. Hossain c Taylor b Sodhi 19
S. Gazi c Williamson b Wagner 14
A. Razzak b Sodhi 13
R. Hossain c Watling b Wagner 4
A. Hossain not out 0
Extras (1w, 1lb, 2b) 4
Total (74.5 overs) 282
Fall: 1-23, 2-90, 3-166, 4-208, 5-228, 6=246, 7-252, 8-266, 9-274.
Bowling: T. Boult 16-2-55-1, D. Bracewell 14-1-57-0 (1w), N. Wagner 19-5-64-5, I. Sohi 18.5-3-59-3, K. Williamson 4-0-30-0, C. Anderson 3-0-14-1.
New Zealand
First innings:
P. Fulton lbw b al-Hasan 14
H. Rutherford c M. Haque b al-Hasan 13
K. Williamson not out 28
R. Taylor not out 37
B. McCullum c R. Hossain b al-Hasan 11
Extras (4b) 4
Total (for 3 wkts, 33.3 overs) 107
Fall: 31 (Rutherford), 32 (Fulton), 101 (McCullum).
Bowling: A. Hossain 6-3-14-0, S. Gazi 6-0-13-0, S. al-Hasan 11-1-25-3, A. Razzak 5-1-33-0, R. Hossain 5.3-0-18-0.