The functionality of many magnetic materials critically depends on first manipulating and then taking advantage of highly non-linear changes of properties that occur during phase transformations. Unique to lanthanides, property-defining 4f electrons are highly localized and, as commonly accepted, play little to no role in chemical bonding. Yet here we demonstrate that the competition between 4f-electron energy landscapes of Dy (4f 9) and Er (4f 11) is the key element of the puzzle required to explain complex interplay of magnetic and structural features observed in Er 1-x Dy x Co 2, and likely many other mixed lanthanide systems. Unlike the parent binaries-DyCo 2 and ErCo 2-Er 1-x Dy x Co 2 exhibits two successive magnetostructural transitions: a first-order at T C , followed by a secondorder in the ferrimagnetically ordered state. Supported by first principles calculations, our results offer new opportunities for targeted design of magnetic materials with multiple functionalities, and also provide a critical insight into the role of 4f electrons in controlling the magnetism and structure of lanthanide intermetallics.