Shape-memory alloys (SMAs), which display shape recovery upon heating, as well as superelasticity, offer many technological advantages in various applications. Those distinctive behaviors have been observed in many polycrystalline alloy systems such as nickel titantium (TiNi)-, copper-, iron-, nickel-, cobalt-, and Ti-based alloys but not in lightweight alloys such as magnesium (Mg) and aluminum alloys. Here we present a Mg SMA showing superelasticity of 4.4% at -150°C and shape recovery upon heating. The shape-memory properties are caused by reversible martensitic transformation. This Mg alloy includes lightweight scandium, and its density is about 2 grams per cubic centimeter, which is one-third less than that of practical TiNi SMAs. This finding raises the potential for development and application of lightweight SMAs across a number of industries.