Magnetic fields are a very special form of elastic medium. Within astrophysical environments (magnetized stars and protogalaxies) they counteract shear and rotational distortions as well as gravitational collapse. Their vector nature allows for their extraordinary coupling with space–time curvature in the framework of general relativity. This particular coupling points out the way to study magnetic elasticity under gravitational deformation. In this context, we reveal their law of elasticity, calculate their fracture limit and subsequently argue that they ultimately lose the battle against gravitational contraction of magnetized matter. Two illustrative applications, in a neutron star and a white dwarf, accompany the results.