The influence of a poloidal magnetic field on the onset of convection in spherical shells of a compressible fluid is investigated. It is shown that, provided the change in the gravitational field produced by the convective motions can be neglected, a separate stability criterion can be found on each field line. A variational method is used to obtain explicit stability criteria for two very artificial models of a star containing a magnetic field. It appears that very large fields indeed would be required to suppress convection in an entire spherical shell unless the superadiabatic excess is very small; it is relatively easy to satisfy the stability criterion in regions where the field is predominantly vertical but very difficult where it is mainly horizontal. Although the problem cannot be solved in the same way if the field has a toroidal component, it does not seem likely that such a horizontal field would be stabilizing. The changes of the gravitational field are a destabilizing influence but they are likely to be unimportant if both the layer thickness and the pressure scale height are small compared to the local gravitational Jean's length. It is pointed out that if linear theory predicts that one part of the shell is stable whilst another part is unstable, this property may not persist when fully developed convection occurs in the unstable region.