Temporal instability of liquid-metal flow in a square duct is investigated using a two-dimensional Chebyshev collocation method. In this study, the flow is subjected to a transverse magnetic field. The wall of the duct perpendicular to the magnetic field and the left parallel wall is perfectly conducting whereas the right parallel wall is insulating. Neutral stability curves are obtained for different Hartmann numbers. The five influencing factors of the instability are analyzed by energy analysis of perturbations. With the increase of Hartmann number, the critical Reynolds number first decreases rapidly and then increases gradually. The turning point of the variation of Rec with Ha is at Ha ≈ 20.4. When Ha < 20.4, velocity shear near the inflection point plays a dominant role in leading to the flow instability. When Ha becomes >20.4, perturbations produced by the inflectional velocity profile and Tollmien-Schlichting waves in the side layer are elongated by the nonuniform velocity in transverse direction; thus, the flow instability is caused by the combined effect at a much lower Reynolds number.