The steady magnetic fields were utilized to decrease the porosity of aluminum alloy laser welded joints, and the effect is related to the magnetic field orientation. The influence of the magnetic field orientation on the suppression of porosity was investigated by establishing a three-dimensional heat flow model coupled with magnetohydrodynamics (MHD) and free surface of a keyhole. The Lorentz force decreased the backflow velocity toward the keyhole wall when the magnetic fields were horizontally parallel to the welding direction (magnetic field X-axis, MFX) and perpendicular to the welding direction (magnetic field Y-axis, MFY), thereby clearly improving the keyhole stability. Additionally, the melt flows in the rear region of the molten pool were suppressed downward and forward under the MFX and MFY, respectively, leading to additional heat accumulation in the rear periphery of the molten pool. As a result, a long molten pool in the longitudinal section and a small penetration depth were observed under the MFX and MFY. Therefore, the porosity defects decreased from 9.4% to 3.5% and 3.2% under the MFX and MFY, respectively. However, many pores were observed when the magnetic field orientation was vertical (magnetic field Z-axis, MFZ), owing to the high penetration depth and poor keyhole stability. This study provides a deeper understanding of the effect of magnetic fields on the laser welding of aluminum alloys and potentially lays a foundation for the adjustment of suitable magnetic field parameters toward obtaining the desired effect.