Much of the universe's water is produced as a byproduct of star formation. When stars are born, their birth is accompanied by a strong outward wind of gas and dust. When this outflow of material eventually impacts the surrounding gas, the shock waves that are created compress and heat the gas. The water observed is quickly produced in this warm dense gas.
In 2011 a report described the discovery of a gigantic cloud of water vapor containing 140 trillion times more water than all of Earth's oceans combined around a quasar located 12 billion light years from Earth. According to the researchers, the discovery shows that water has been prevalent in the universe for nearly its entire existence.
Water has been detected in interstellar clouds within our galaxy, the Milky Way. Water probably exists in abundance in other galaxies, too, because its components, hydrogen and oxygen, are among the most abundant elements in the universe. Based on models of the formation and evolution of the Solar System and that of other star systems, most other planetary systems are likely to have similar ingredients.