We analyse numerically the linear stability of the fully developed flow of a liquid metal in a square duct subject to a transverse magnetic field. The walls of the duct perpendicular to the magnetic field are perfectly conducting whereas the parallel ones are insulating. In a sufficiently strong magnetic field, the flow consists of two jets at the insulating walls and a near-stagnant core. We use a vector stream function formulation and Chebyshev collocation method to solve the eigenvalue problem for small-amplitude perturbations. Due to the two-fold reflection symmetry of the base flow the disturbances with four different parity combinations over the duct cross-section decouple from each other. Magnetic field renders the flow in a square duct linearly unstable at the Hartmann number Ha ≈ 5.7 with respect to a disturbance whose vorticity component along the magnetic field is even across the field and odd along it. For this mode, the minimum of the critical Reynolds number Rec ≈ 2018, based on the maximal velocity, is attained at Ha ≈ 10. Further increase of the magnetic field stabilizes this mode with Rec growing approximately as Ha. For Ha > 40, the spanwise parity of the most dangerous disturbance reverses across the magnetic field. At Ha ≈ 46 a new pair of most dangerous disturbances appears with the parity along the magnetic field being opposite to that of the previous two modes. The critical Reynolds number, which is very close for both of these modes, attains a minimum, Rec ≈ 1130, at Ha ≈ 70 and increases as Rec ≈ 91Ha1/2 for Ha ≫ 1. The asymptotics of the critical wavenumber is kc ≈ 0.525Ha1/2 while the critical phase velocity approaches 0.475 of the maximum jet velocity.