Massive stars end their short lives in spectacular explosions-supernovae-that synthesize new elements and drive galaxy evolution. Historically, supernovae were discovered mainly through their 'delayed' optical light (some days after the burst of neutrinos that marks the actual event), preventing observations in the first moments following the explosion. As a result, the progenitors of some supernovae and the events leading up to their violent demise remain intensely debated. Here we report the serendipitous discovery of a supernova at the time of the explosion, marked by an extremely luminous X-ray outburst. We attribute the outburst to the 'break-out' of the supernova shock wave from the progenitor star, and show that the inferred rate of such events agrees with that of all core-collapse supernovae. We predict that future wide-field X-ray surveys will catch each year hundreds of supernovae in the act of exploding.