In magnetic resonance imaging (MRI), it is possible to cancel the effects of severe inhomogeneities of the magnetic field even if the field profile is unknown. The new ‘cross-encoded’ method is based on adiabatic frequency-modulated pulses combined with two orthogonal gradients that are applied simultaneously during encoding and decoding. Undistorted two- and three-dimensional images can be obtained in inhomogeneous fields where the breadth of the water resonance extends over several kHz.