The heavy rare earth elements crystallize into hexagonally close packed (h.c.p.) structures and share a common outer electronic configuration, differing only in the number of 4f electrons they have1. These chemically inert 4f electrons set up localized magnetic moments, which are coupled via an indirect exchange interaction involving the conduction electrons. This leads to the formation of a wide variety of magnetic structures, the periodicities of which are often incommensurate with the underlying crystal lattice2. Such incommensurate ordering is associated with a 'webbed' topology3, 4 of the momentum space surface separating the occupied and unoccupied electron states (the Fermi surface). The shape of this surface—and hence the magnetic structure—for the heavy rare earth elements is known to depend on the ratio of the interplanar spacing c and the interatomic, intraplanar spacing a of the h.c.p. lattice5. A theoretical understanding of this problem is, however, far from complete. Here, using gadolinium as a prototype for all the heavy rare earth elements, we generate a unified magnetic phase diagram, which unequivocally links the magnetic structures of the heavy rare earths to their lattice parameters. In addition to verifying the importance of the c/a ratio, we find that the atomic unit cell volume plays a separate, distinct role in determining the magnetic properties: we show that the trend from ferromagnetism to incommensurate ordering as atomic number increases is connected to the concomitant decrease in unit cell volume. This volume decrease occurs because of the so-called lanthanide contraction6, where the addition of electrons to the poorly shielding 4f orbitals leads to an increase in effective nuclear charge and, correspondingly, a decrease in ionic radii.