Stars form within large clouds of gas and dust known as stellar nurseries. Of course, when a star forms, that leaves less gas and dust to form other stars. So you can do a bit of simple math concerning star formation. Take the rate at which new stars form in a galaxy (and their typical mass), compare that to the amount of gas and dust a galaxy has, and you can estimate the time over which stars can form.
For a spiral galaxy such as the Milky Way, this calculation tells us that, at the given rate of star formation, it can only keep producing stars for about a billion years. This raises a bit of a puzzle, because the Milky Way is far older than a billion years, so how does it have enough gas and dust to keep producing stars?
Part of it comes from the gas and dust given off by supernovas, but that isn’t sufficient to keep things going over billions of years. It has been assumed that another source comes from outside the galaxy itself. We know that galaxies tend to cluster together. Our local group, for example consists of the Milky Way, the Andromeda and Triangulum spiral galaxies, and lots of other smaller galaxies. Since galaxies cluster, it is reasonable to assume that intergalactic hydrogen also clusters. This intergalactic gas would gradually be attracted to nearby galaxies, where it could become part of stellar nurseries.
But mapping this intergalactic hydrogen is difficult, because it is generally cold and neutral. So while we’ve suspected it as a source of gas, its been hard to prove. This month in Nature researchers presented a map of neutral hydrogen between the Andromeda and Triangulum galaxies, and the results support the idea of intergalactic gas as a source for stellar formation.
You can see an image of this gas in the figure. The upper figure is a high resolution image, while the lower figure is an averaged image. What it shows is that about half the gas is clumped into discrete regions, while the other half is relatively diffuse. The total mass of this gas is about 2.6 million solar masses, which is plenty of material for star formation.
It seems even galaxies have a gas station.