Scientists have observed the immediate aftermath of a supernova for the first time, detecting a brilliant display of light from the death of a red supergiant star just 3 hours after it exploded.

The event, called SN 2013fs, is the first chance researchers have had to study a supernova in such a state of extreme infancy – light cast by stellar explosions usually takes at least several days to discover. On this occasion, astronomers got lucky, as space telescopes just happened to be gazing at the right portion of the night sky at the right time.

The supernova occurred in a galaxy called NGC 7610, which is approximately 160 million light-years away.

After the light from this ancient explosion travelled for 160 million years through space, it finally reached Earth in 2013, where it was detected by chance during an automated sky survey being run at the Palomar Observatory near San Diego, California.

"Until several years ago, catching a supernova even a week after explosion was regarded as early," astrophysicist Ofer Yaron from the Weizmann Institute of Science in Israel told ResearchGate.

"This is not the case anymore, and with new wide-field automated and fully robotic sky surveys, we have begun catching events a day or less after explosion."

By picking up the light show from supernovae just hours after they happen, scientists get a rare opportunity to examine the cosmic conditions surrounding a star just prior to when it explodes.

Supernovae occur when a star runs out of its nuclear fuel toward the end of its lifetime. As the star begins to feed on its own core, the core collapses, resulting in a huge explosion.

In the case of binary stars, supernovae can occur when one of the stars accumulates too much matter from its companion star.

While the light from supernovae is usually observable for about a year, you have to get in quick if you want to study the landscape of the early event – the force of the explosion blasts the star's matter outward at speeds of around 10,000 kilometres (6,213 miles) per second.

In the case of SN 2013fs, observations showed that the star was surrounded by a disk of material that had been ejected by the star in the year or so leading up to the supernova.

This layer of matter shrouded the star in a cloud of gas some 10 billion kilometres (6.2 billion miles) thick, before being obliterated by the supernova's epic finale.

"Before going supernova, the star experiences very significant instabilities in its interior, affecting the outer envelopes and surface, which causes this elevated, maybe even eruptive, mass loss, just before the explosion," Yaron explained to Becky Ferreira at Motherboard.

"It's as if the star knows that it is finishing its life soon, that it will die soon, and it puffs some material outside in its last breaths."

SN 2013fs was what's called a Type II supernova – the most common type of stellar explosion, involving stars with between eight to 50 times the mass of our Sun.

Because of this commonality, the researchers think it's possible that other dying stars might also exhibit this 'mass-loss' behaviour in their final days, resulting in similar encircling matter clouds before the supernova eventuates.

If that's so, it will help scientists to better understand the processes involved in the lead-up to these gigantic explosions.

"[T]he fact that [SN 2013fs] was found to be a fairly normal type II with circum-stellar material means that this phenomenon of elevated – maybe even eruptive – mass-loss just before the final supernova explosion is common among core-collapse supernovae," Yaron told Maarten Rikken at ResearchGate.

The good news is it might not be too long before we find out just how common this actually is.

Yaron says advances being made in telescopes and sky surveys mean that we might soon be able to detect supernovas in even shorter time frames – even within minutes.

That ability will help scientists study these hugely violent star deaths in ever greater detail – and if we're lucky, we might even get a chance to observe one in our own galaxy.

"If you ask swimmers in the sea, they don't want to see sharks. But if you ask divers, that's all they want to see," Yaron told Ian Sample at The Guardian.

"It's the same thing. We all hope there will be a supernova in the Milky Way soon. As long as it's not too near."

The findings are reported in Nature Physics.