In this paper the effects of a magnetic field on mixed convection flow in a two‐sided lid‐driven cavity have been analyzed by the lattice Boltzmann method (LBM). The Hartmann number varied from Ha = 0 to 100. The study has been conducted for different Richardson numbers (Ri) from 0.01 to 100 while the direction of the magnetic field was investigated in the x‐direction. Consequences demonstrate that the heat transfer augments with an increment of the Richardson number for different Hartmann numbers for two cases. The heat transfer declines with the growth of the magnetic field for various Richardson numbers for two cases. The difference between the values of heat transfer for the two cases at variant parameters is negligible but the trend of fluid flow for the two cases is multifarious.