The hosts, who plodded to 193-3 on the opening day after electing to bat, made 433 in their first innings before being dismissed in the final session of the second day.
Zimbabwe ended the day on 53-1, still trailing by 380 runs with nine wickets in hand, after left-arm spinner Taijul Islam trapped Sikandar Raza leg-before for 11.
Hamilton Masakadza was unbeaten on 15 and Brian Chari was on 21 when stumps were drawn.
Bangladesh lead the three-match series 1-0 after winning the first Test in Dhaka by three wickets.
The left-handed pair of Tamim and Shakib put Bangladesh on top with a fourth-wicket stand of 132 on a slow pitch.
Shakib made 137, his third Test century, with the help of 18 boundaries and two sixes.
Tamim scored a painstaking 109, his fifth Test hundred and the first in four years, with 10 fours.
When Tamim reached 100 off 312 balls, he recorded the slowest Test century by a Bangladeshi batsman — surpassing his elder brother Nafees Iqbal, who needed 309 deliveries to reach a hundred against the same opponents in 2005.
Bangladesh captain Mushfiqur Rahim played 31 consecutive dot balls before he was run out for 11, but Shakib broke free to reach his century with a straight drive off Tinashe Panyangara.
Tamim fell to part-timer Masakadza, before Malcolm Waller dismissed Shakib and Shuvagata Hom (15) to ease the pressure on Zimbabwe.
Taijul hit a quick-fire 32 off 44 balls to carry Bangladesh past the 400-run mark.
Tendai Chatara got rid of Taijul and Shahadat Hossain, before Natsai M’shangwe wrapped up the innings by claiming Jubair Hossain leg-before to earn his maiden Test wicket.
The third Test between the two lowest-ranked teams — Zimbabwe at number nine and Bangladesh at 10 — will be played in Chittagong from November 12-16.
The Tests will be followed by five one-day internationals- AFP