Abstract-This paper examines the natural convection in a square enclosure filled with a water-Al 2 O 3 nanofluid and is subjected to a magnetic field. The side walls of the cavity have spatially varying sinusoidal temperature distributions. The horizontal walls are adiabatic. Lattice Boltzmann method (LBM) is applied to solve the coupled equations of flow and temperature fields. This study has been carried out for the pertinent parameters in the following ranges: Rayleigh number of the base fluid, Ra=10 3 to 10 6 , Hartmann number varied from Ha=0 to 90, phase deviation (γ=0, π/4, π/2, 3π/4 and π) and the solid volume fraction of the nanoparticles between Ø = 0 and 6%. The results show that the heat transfer rate increases with an increase of the Rayleigh number but it decreases with an increase of the Hartmann number. For γ=π/2 and Ra=10 5 the magnetic field augments the effect of nanoparticles. At Ha=0, the greatest effects of nanoparticles are obtained at γ = 0 and π/4 for Ra=10 4 and 10 5 respectively.