In the 1960s a series of satellites were built as part of Project Vela. Project Vela was intended to detect violations of the 1963 ban on above ground testing of nuclear weapons. The Vela satellites were designed to detect bursts of gamma rays, which are high energy electromagnetic waves produced by radioactive decay. If any nuclear weapon was detonated in space, the resulting radioactive decay would release a large amount of gamma rays which would be detected by the Vela satellites.
In 1967, two of the Vela probes detected a large spike of gamma rays. But the signature of this spike was very different from those of a nuclear explosion. Soon more gamma ray spikes were detected, and these likewise differed from the expected signature of a nuclear test. Since the bursts were observed by multiple satellites, the Vela team was able to compare the arrival of the bursts between different satellites, and it soon became clear that the bursts had an extraterrestrial source. Of course the Vela project was classified, so it wasn't until 1973 that the results were declassified and published in Astrophysical Journal. It was only then that astronomers were made aware of these gamma ray bursts (GRBs).
We now know that GRBs are very common. On average, about one gamma ray burst occurs every day. They appear randomly in all directions of the sky, and this means they aren't produced in our galaxy. If they were, then GRBs would mostly be found along the plane of the Milky Way.
Some gamma ray bursts (known as long bursts) can last more than two seconds. These bursts have afterglow caused by gamma rays colliding with interstellar material near the event, causing the emission of light at other wavelengths. This afterglow allows us to measure the redshift of these events, and what we find is that they are quite distant. The closest observed gamma ray burst occurred at a distance of 100 million light years, and many occurred billions of light years away.
We aren't entirely sure what causes a gamma ray burst. Because of their distance, and apparent brightness, they must be extraordinarily energetic, with about 100 times more energy than a supernova. They may be caused by huge supernova explosions known as hypernova, or they may be caused by supernova explosions occur with a rotational axis pointing in our direction, causing a jet-like burst of energy. Short burst GRBs, lasting less than 2 seconds, may be due to collisions between neutron stars.
Given the huge energy of GRBs, one might wonder if one could occur in our galaxy. Given the average rate of GRBs and the huge distances at which they typically occur, the rate at which one happens in our galaxy is probably about once every 5 million years.