Many practical applications exploit an external local magnetic field – magnetic obstacle – as an essential part of their operation. It has been demonstrated that the flow of an electrically conducting fluid influenced by an external field can show several kinds of recirculation. The present paper reports a three-dimensional numerical study, some results of which are compared with an experiment on such a flow in a rectangular duct. First, we derive equations to compute analytically the external magnetic field and verify these equations by comparing with experimentally measured field intensity. Then, we study flow characteristics for different magnetic field configurations. The flow inside the magnetic gap is dependent mainly on the interaction parameter N, which represents the ratio of the Lorentz force to the inertial force. Depending on the constrainment factor κ = My/Ly, where My and Ly are the half-widths of the external magnet and duct, the flow can show different stationary recirculation patterns: two magnetic vortices at small κ, a six-vortex ensemble at moderate κ, and no vortices at large κ. Recirculation appears when N is higher than a critical value Nc,m. The driving force for the recirculation is the reverse electromotive force that arises to balance the reverse electrostatic field. The reversal of the electrostatic field is caused by the concurrence of internal and external vorticity respectively related to the internal and external slopes in the M-shaped velocity profile. The critical value of Nc,m grows quickly as κ increases. For the case of well-developed recirculation, the numerical reverse velocity agrees well with that obtained in experiments. Two different magnetic systems can induce the same electric field and stagnation region provided these systems have the same power of recirculation, given by the N/Nc,m ratio. The three-dimensional helical characteristics of the vortices are elaborated, and an analogy is shown to exist between helical motion inside the recirculation studied and secondary motion in Ekman pumping. Finally, it is shown that a two-dimensional model fails to properly produce stable two- and six-vortex structures as found in the three-dimensional system. Interestingly, these recirculation patterns appear only as time-dependent and unstable transitional states before a Kármán vortex street forms, when one suddenly applies a retarding local magnetic field to a constant flow.