Some observations suggest that very massive stars experience extreme mass-loss episodes shortly before they explode as supernovae, as do several models. Establishing a causal connection between these mass-loss episodes and the final explosion would provide a novel way to study pre-supernova massive-star evolution. Here we report observations of a mass-loss event detected 40 days before the explosion of the type IIn supernova SN 2010mc (also known as PTF 10tel). Our photometric and spectroscopic data suggest that this event is a result of an energetic outburst, radiating at least 6 × 10$^47$ erg of energy and releasing about 10$^-2$ solar masses of material at typical velocities of 2,000 km s$^-1$. The temporal proximity of the mass-loss outburst and the supernova explosion implies a causal connection between them. Moreover, we find that the outburst luminosity and velocity are consistent with the predictions of the wave-driven pulsation model, and disfavour alternative suggestions.