During the height of the Cold War, a few US spy satellites changed our view of the Universe forever.
In 1963, a year after the Cuban Missile Crisis nearly plunged the world into nuclear war, the US launched a set of spacecraft to keep an eye on the Soviet Union.
They're so bright that they shine across vast stretches of space and time
The two superpowers had just signed a treaty that banned nuclear testing in the atmosphere and in space. From about 100,000 kilometres above Earth, these Vela satellites would make sure the Soviets complied.
They were designed to detect high-energy radiation called gamma rays, which are produced in nuclear explosions. In 1967, the satellites began detecting several mysterious bursts of radiation. But the blasts did not seem to be nuclear bombs. They were coming from outer space.
The discovery of these cosmic curiosities was kept secret until 1973. No one knew what they were, and for decades, these gamma-ray bursts confounded scientists.
But as the Cold War thawed, thanks to multiple spacecraft and telescopes, astronomers have gained a better understanding of these bursts. Today, they have found about 6,000, estimating that a couple flash in the sky every day.
They come from some of the Universe's most exotic objects: black holes and ultra-dense stellar corpses called neutron stars. They're so bright that they shine across vast stretches of space and time, revealing clues about the origins of the first stars.
Because of their ephemeral nature – as brief as a few milliseconds – gamma-ray bursts reveal a Universe that's more dynamic than previously thought. Astronomers are learning that even in human timescales, the cosmos is an explosive and ever-changing place.
The mystery deepens
Gamma rays are about as extreme as you can get. "They're the brightest, most powerful explosions in the Universe," says Andrew MacFadyen, an astrophysicist at New York University, US.
The bursts are a million times brighter than entire galaxies. Per second, a single gamma-ray burst can produce as much energy as all the starlight in the observable Universe, he says.
They are the most energetic form of electromagnetic radiation, and in space, they are signs of the hottest, most powerful processes in the Universe – such as solar flares and black holes gobbling up gas and dust.
But because Earth's atmosphere absorbs the rays, the gamma-ray universe was closed off to astronomers until the space age.
It was only when spacecraft like Vela were launched that scientists could glimpse cosmic gamma rays. Only then could they discover gamma-ray bursts
"Most of the things we study in astronomy are things we've known about for a long time, like stars, galaxies, and planets," says Edo Berger, an astronomer at Harvard University, US. "But here, there was a completely accidental discovery of something that nobody could even imagine existed."
Some bursts were short-lived, flaring for only a few milliseconds
Satellites like Vela continued to discover more, but without a scientific instrument designed to study the bursts, the data remained limited. No one even knew how far away the bursts were. But nearly 20 years after their discovery, answers were starting to emerge.
In 1991, Nasa launched the Compton Gamma Ray Observatory, equipped with the first gamma-ray burst instrument, called BATSE, for the Burst and Transient Source Experiment.
The instrument detected hundreds of bursts and it soon became apparent that they came in two distinct classes.
Some bursts were short-lived, flaring for only a few milliseconds. Others were longer, glowing for 30 seconds or more. This revelation meant that the two types must originate from two very different phenomena.
But to identify those phenomena, astronomers needed to know where they came from. If the bursts were local, exploding in our own, disk-shaped Milky Way Galaxy, they should align with the galactic plane, appearing along a strip in the sky.
But BATSE found the bursts were distributed evenly across the sky, suggesting they came from outside our galaxy.
Measuring how much the radiation has stretched by the time it reaches Earth can tell you how far away the burst is
While persuasive, this evidence was circumstantial. Astronomers needed to determine exactly how far away the bursts were. For that, they had to find an afterglow, the smouldering radiation that lingers after gamma rays fade.
The afterglow, which appears in other wavelengths such as visible light and X rays, contains the chemical fingerprint of the burst: radiation that glows at specific wavelengths. As that radiation zooms toward Earth, the expanding Universe stretches it to longer wavelengths.
This expansion rate increases with distance, which means that measuring how much the radiation has stretched by the time it reaches Earth can tell you how far away the burst is.
But BATSE was more of a detector than a telescope, so it was unable to pinpoint the bursts in the sky. Without a precise location, other telescopes could not follow up in time to catch an afterglow.
That changed in 1996, when Italy and the Netherlands launched BeppoSax, a gamma-ray telescope that could locate bursts with greater precision.
When a star exhausts its fuel, its core can collapse into a neutron star
In 1997, the satellite identified a powerful burst. Immediately, telescopes pointed in the same direction and caught an afterglow. This allowed astronomers to measure the distance to a gamma-ray burst for the first time.
The result was conclusive: it was indeed beyond the edge of our galaxy – six billion light years away.
There was a caveat, however. BeppoSax wasn't quick enough to catch the afterglow of short bursts, which meant they would remain a mystery for the time being.
Instead, over the next few years a more accurate picture of the long bursts started to come into focus.
Scientists long suspected that it involved an extreme object such as a black hole or a neutron star. Only such dense objects, with strong gravitational and magnetic fields, could produce bursts so brief and intense.
The bursts must be dying stars that explode with so much energy they produce gamma rays
Both emerge from the violent deaths of massive stars. When a star exhausts its fuel, its core can collapse into a neutron star. If it's massive enough, it will collapse into a black hole, so dense that even light cannot escape its gravity. Meanwhile, the star blows off its outer layers in a huge explosion called a supernova.
Supernovae are bright, and once astronomers could easily locate gamma-ray bursts, they found that they always coincided with supernovae. The bursts, they reasoned, must be dying stars that explode with so much energy they produce gamma rays.
But it's a rare scenario: Only about one percent of all supernovae are associated with a gamma-ray burst.
After the star collapses into a black hole, the remaining gas forms a disk that swirls into the black hole like water circling a drain. As the material falls, it releases tremendous amounts of energy – some in the form of powerful jets that erupt at near light speed from the black hole's poles. Those jets generate beams of gamma rays, which, when they point at Earth, appear as a gamma-ray burst.
Most astronomers agree this is the most compelling explanation. "The picture really holds together," MacFadyen says. "However, you want to be certain."
Indeed, many questions still remain. For example, it remains unclear whether the source of the burst is a black hole or a neutron star. We also do not know exactly how the jets are produced, what they are made of, and how exactly they generate gamma rays.
At the turn of the 21st century, however, one of the biggest mysteries confronting gamma-ray astronomers was the origin of short bursts. As with their longer lasting cousins, the key was in catching the afterglow, which was beyond the capabilities of any instrument at the time.
Again, astronomers needed another spacecraft. It came in 2004, when Nasa launched Swift. Fitted with telescopes to study afterglows of X rays and visible light, the spacecraft was quick enough to point them at even the shortest bursts.
In just six months, the spacecraft found one.
"We realised within the first day – within the first hours – that it was different from the long bursts," says Neil Gehrels, the leader of the Swift mission. "It wasn't coming from an exploding star."
Unlike long bursts, this one didn't come with any supernova explosions, despite numerous telescopes looking out for one. The burst also came from a different kind of galaxy.
It took a few more bursts before we were absolutely convinced it was merging neutron stars
Long bursts had all originated in spiral galaxies like the Milky Way, fertile places where lots of stars are born. The exploding stars responsible for the long bursts had to be massive, and massive stars live fast and die young.
Long bursts would therefore be common where lots of these stars formed and died. But Swift's burst came from a galaxy filled with old or dead stars. If any had blown up, they would have done so a long time ago.
All signs pointed to one leading hypothesis: the violent collision of two neutron stars. Astronomers estimate that the Universe is full of pairs of neutron stars in orbit around each other. Over time, they spiral towards each other until they merge, erupting in a huge burst of energy and, possibly, gamma rays.
As Swift detected more bursts, this scenario looked better and better. "It took a few more bursts before we were absolutely convinced it was merging neutron stars," Gehrels says.
Still, most of the evidence is circumstantial. Although all observations so far are consistent with a neutron-star merger, no one has found conclusive evidence. For example, MacFadyen says, a similar collision between a neutron star and a black hole might also produce a short burst.
It would be indisputable evidence that links merging neutron stars with short bursts
But further proof could come soon. When two orbiting neutron stars circle towards each other, they lose energy in the form of ripples in the fabric of space and time, called gravitational waves, which travel across the Universe. These waves, predicted by Einstein a century ago, were directly detected for the first time in 2015 by the Laser Interferometer Gravitational-wave Observatory (LIGO) in the US.
LIGO's revolutionary discoveries – two so far – came from merging black holes. But the observatory should also be able to measure waves from merging neutron stars.
"That would be an incredible thing," MacFadyen says. "You would see a single event that's producing both a really bright gamma-ray burst and a really bright gravitational-wave burst at the same time." It would be indisputable evidence that links merging neutron stars with short bursts.
A new Universe
Today, gamma-ray bursts are no longer the mystery they once were. "It's been an amazing adventure," says Gehrels. While many researchers are probing the inner workings of both long and short gamma-ray bursts, others see the bursts as cosmic beacons from the past.
Because the bursts are so bright, they're visible across vast distances – and vast stretches of time. The most distant burst ever seen comes from a time when the Universe was only 400 million years old. Yet farther bursts could signal the explosive deaths of the earliest stars.
"We really will be able to see the first stars in the Universe – at least, when they die," Berger says. "The idea that we can see an individual star explode when it's one of the first generation of stars in the Universe is really amazing."
That's not all. The light from the burst can also contain the chemical fingerprint of the gasses that surround the burst.
Stars, planets, galaxies – they all exist as they are, more or less, for billions of years
By analysing that light from bursts at different distances, astronomers can determine which chemical elements were present at various stages of cosmic history. This kind of chemical history is essential for understanding how the Universe evolved and came to be.
But perhaps the most lasting legacy of gamma-ray bursts is how they have changed our perspective of the cosmos. "When you think of most things in the Universe, they last forever in human timescales," Berger says. Stars, planets, galaxies – they all exist as they are, more or less, for billions of years.
But the discovery of gamma-ray bursts revolutionised that view. "Here we have things that appear and disappear in hours, minutes, or seconds."
It's now clear that the study of gamma-ray bursts has paved the way for a new kind of astronomy. Telescopes are now constantly watching the sky for sudden flickers and flashes of light at all wavelengths. These signals could be supernovae, flaring galaxies powered by supermassive black holes, or something still to be discovered.
All this points to the fact that our Universe is extremely dynamic. And to explore it, astronomers must be on their toes. Otherwise, it may just pass them by.
Join over five million BBC Earth fans by liking us on Facebook, or follow us on Twitter and Instagram.
If you liked this story, sign up for the weekly bbc.com features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.