In this paper, the effect of magnetic field on natural convection of Al2O3/water nanofluid in an enclosure containing twin protruding heat sources placed on top and bottom walls arranged in-line and staggered manner is presented. For this purpose, coupled equations governing fluid flow and heat transfer are solved in Cartesian framework using streamline upwind/Petrov–Galerkin (SUPG) finite element method. Numerical computations are performed to predict the fluid flow, heat transfer, and entropy generation for a wide range of Hartmann number (0.0 Ha 100.0), Rayleigh number (), and nanoparticle volume fraction (). The simulated results indicate that, for both in-line and staggered arrangement, the entropy generation due to heat transfer is significant along isothermal surfaces, whereas entropy generation due to fluid friction is higher at no-slip walls and along the regions of contact between adjacent recirculation cells. For both in-line and staggered arrangement, increase in global total entropy generation and average Nusselt number along top and bottom heat sources is obtained with decreasing Ha and increasing Ra. Furthermore, for both in-line and staggered arrangement, variation in global total entropy generation and average Nusselt number along top and bottom heat sources with increasing nanoparticle volume fraction, depend on both Ha and Ra.