For decades, scientists were at a loss to explain the source of the so-called Magellanic Stream, a long ribbon of gas discovered in the early 1970s that extends nearly halfway around the Milky Way.

But new data from NASA's Hubble Space Telescope have helped astronomers crack the case. The observations show that the stream did not form all at once; instead, the ribbon is a combination of material stripped at different times from both the Large Magellanic Cloud and the Small Magellanic Cloud, two satellite galaxies that hover around the Milky Way less than 200,000 light years away.

About 2 billion years ago, material was pulled from the Small Magellanic Cloud, creating part of the gassy filament, while a second region of the stream originated more recently from the Large Magellanic Cloud, the researchers say. [See the Latest Amazing Photos from the Hubble Space Telescope]

The image, taken at radio wavelengths, is a close-up map of the Magellanic Stream that was generated from the Leiden-Argentine-Bonn (LAB) Survey. (Image credit: Leiden-Argentine-Bonn (LAB) Survey)

The team determined the source of the ribbon by measuring the abundances of heavy elements at six locations different along the Magellanic Stream using Hubble's Cosmic Origins Spectrograph, according to a statement from NASA. (Scientists can detect theses faraway heavy elements through the way they absorb ultraviolet light.)

Low levels of oxygen and sulfur found throughout most of the stream match the chemical makeup of the Small Magellanic Cloud, the researchers said. But they also found a surprising amount of sulfur in a part of the stream that's closer to the Magellanic Clouds.

"We're finding a consistent amount of heavy elements in the stream until we get very close to the Magellanic Clouds, and then the heavy element levels go up," study researcher Andrew Fox of the Space Telescope Science Institute in Baltimore, Md., said in a statement. "This inner region is very similar in composition to the Large Magellanic Cloud, suggesting it was ripped out of that galaxy more recently."

These companion images show wide and close-up views of the long ribbon of gas known as the Magellanic Stream, which stretches nearly halfway around our Milky Way galaxy. The location of the Large Magellanic Cloud (LMC) and the Small Magellanic Cloud (SMC) are noted in the bottom image. (Image credit: David L. Nidever et al., NRAO/AUI/NSF and A. Mellinger, LAB Survey, Parkes Observatory, Westerbork Observatory, and Arecibo Observatory)

By studying the stream, researchers could learn more about how larger galaxies affect their surrounding satellite galaxies, Fox explained.

"We want to understand how galaxies like the Milky Way strip the gas from small galaxies that fall into them and then use it to form new stars," he added in a statement. "This seems like it's an episodic process. It's not a smooth process where a slow stream of gas comes in continuously. Instead, once in a while a large gas cloud falls in. We have a way of testing that here, where two galaxies are coming in. We've shown which of them is producing the gas that ultimately will fall into the Milky Way."

The findings were detailed in two papers that appeared in the Aug. 1 issue of The Astrophysical Journal.

Follow Megan Gannon on Twitter and Google+. Follow us @SPACEdotcom, Facebook or Google+. Originally published on SPACE.com.