The theory of Grossmann and Lohse [J. Fluid Mech. 407, 27 (2000)] is extended to include the effect of a magnetic field on convection of an electrically conducting fluid. Different scaling laws are obtained depending on whether the bulk or the boundary layers make the major contribution to the dissipation. Scalings are obtained for both weak and strong magnetic fields. The predictions are shown to be in better agreement with experimental data than earlier theoretical models.