In this paper, the effect of a magnetic field on natural convection of non-Newtonian power-law fluids in a cavity with a linearly heated wall has been analyzed by Finite Difference Lattice Boltzmann method (FDLBM). This study has been performed for the certain pertinent parameters of Rayleigh number (Ra=104 and 105), Hartmann number (Ha=0, 15, 30 and 60) and power-law index (n=0.5-1.5) as the magnetic field is applied horizontally. Results indicate that the augmentation of the power-law index in the absence of the magnetic field causes heat transfer to drop. The magnetic field decreases heat transfer in different power-law indexes generally. The increment of the magnetic field power declines the effect of the power-law index on heat transfer. The magnetic field for various Hartmann numbers at Ra=104 provokes heat transfer to increase with the enhancement of power-law index. At Ra=105, the heat transfer falls with the rise of the power-law index for Ha=15 and 30 as the effect is weakened by the increase of Hartmann number significantly. However, the increase in power-law index augments heat transfer at Ha=60.