Sr2IrO4 is a prototype of the class of Mott insulators in the strong spin–orbit interaction (SOI) limit described by a Jeff = 1/2 ground state. In Sr2IrO4, the strong SOI is predicted to manifest itself in the locking of the canting of the magnetic moments to the correlated rotation by 11.8(1)° of the oxygen octahedra that characterizes its distorted layered perovskite structure. Using x-ray resonant scattering at the Ir L3 edge we have measured accurately the intensities of Bragg peaks arising from different components of the magnetic structure. From a careful comparison of integrated intensities of peaks due to basal-plane antiferromagnetism, with those due to b-axis ferromagnetism, we deduce a canting of the magnetic moments of 12.2(8)°. We thus confirm that in Sr2IrO4 the magnetic moments rigidly follow the rotation of the oxygen octahedra, indicating that, even in the presence of significant non-cubic structural distortions, it is a close realization of the Jeff = 1/2 state.