The Earth's mid-ocean ridges display systematic changes in depth and shape, which subdivide the ridges into discrete spreading segments bounded by transform faults and smaller non-transform offsets of the axis1-3. These morphological changes have been attributed to spatial variations in the supply of magma from the mantle, although the origin of the variations is poorly understood1,4,5. Here we show that magmatic segmentation of ridges with fast and intermediate spreading rates is directly related to the migration velocity of the spreading axis over the mantle. For over 9,500 km of mid-ocean ridge examined, leading ridge segments in the 'hotspot' reference frame coincide with the shallow magmatically robust segments across 86 per cent of all transform faults and 73 per cent of all second-order discontinuities. We attribute this relationship to asymmetric mantle upwelling and melt production due to ridge migration, with focusing of melt towards ridge segments across discontinuities. The model is consistent with variations in crustal structure across discontinuities of the East Pacific Rise, and may explain variations in depth of melting and the distribution of enriched lavas.