Mominul Haque struck a century as Bangladesh surged past 300 after starting on 240 for 3.
Rahim, who ended the first session unbeaten on 99, too completed his ton immediately after the break.
Mominul and Rahim scored 222 for the fourth wicket to put Bangladesh on top.
Liton Das made fifty to pile on the misery on Zimbabwe.
Rahim struck his third double ton, and became the highest scorer in Tests for Bangladesh, before the hosts declared on 560 for 6. Zimbabwe were reeling at 9 for 2 at stumps.