The present paper investigates the incompressible, laminar, natural convection flow in a porous square cavity filled with a nanofluid in the presence of magnetic field and viscous dissipation. The nanofluid mathematical model proposed by Buongiorno is considered. The left wall of the enclosure is heated, while the right wall is cooled and the bottom and upper walls are adiabatic. The analysis is formulated in terms of vorticity stream function procedure. The governing equations, which are continuity, momentum, and energy equations, are solved by finite element method based on Galerkin weighted residual approach. The relevant parameters considered for computations are magnetic field, Rayleigh number, thermophoresis, Brownian motion, buoyancy ratio, Lewis number, and Eckert number. The numerical results in terms of streamlines, isotherms, isoconcentrations, the average and local skin friction coefficient and Nusselt numbers are reported for various values of Nt, Nb, Ra, Le, M, and Ec. It is found that the magnetic field, Brownian motion, thermophoretic force, and viscous dissipation show significant effect on the velocity, temperature, and concentration distributions in the cavity.