After more than thirty years, the most striking feature of the internal rotation profile of the Sun as revealed by helioseismology—the tachocline of shear at the base of the convection zone (CZ)—remains poorly understood. Here we present rotating, 3D, spherical-shell simulations of a CZ overlying a stable radiative zone (RZ) that confine the tachocline against inward diffusive spreading via a convective dynamo. In particular, the viscous imprinting of the differential rotation from the CZ onto the RZ is prevented by the non-axisymmetric Lorentz torque, producing a tachocline-like shear layer at all latitudes. The balance remains stable on centuries-long timescales and overall resembles a more complex (non-axisymmetric) version of Ferraro’s Law of Isorotation, in which isorotation contours are forced to fall along poloidal magnetic field lines. These results add an unexpected path toward solving the tachocline confinement problem. Namely, a dynamo operating mostly in the CZ (and notably in the absence of a primordial magnetic field confined beneath the tachocline in the RZ, as suggested in Gough and McIntyre 1998) can by itself stop the inward burrowing of the differential rotation.