London, England (CNN) -- European scientists say they've figured out the recipe for water in space: Just add starlight.

They made the discovery while examining a dying star that is 500 light-years away from Earth, using an infrared observatory launched by the European Space Agency last year.

"This is a good example of how better instruments can change our picture completely," said Leen Decin of the Catholic University of Leuven in Belgium, who is the lead author of the paper about the work.

The story begins in 2001, when astronomers discovered an unexpected cloud of water vapor around an old star called IRC+10216. The star is known as a carbon star, not thought to make much water, so scientists initially thought the star's heat must have evaporated comets or dwarf planets to produce the water vapor.

After the European Space Agency's Herschel laboratory launched last year, however, scientists discovered spectral lines in the light coming from the water vapor.

"Some of these lines can only be there if the temperature is high, otherwise we wouldn't see them," said Goran Pilbratt, a project scientist for the Herschel space observatory. "None of them have been seen before."

Those spectral lines gave scientists a vital clue: The water was hot, with temperatures as high as 800 degrees Celsius (nearly 1,500 degrees Fahrenheit). That meant the water was too hot to have been formed by the destruction of icy celestial bodies, and had to have been formed much closer to the star than comets could stably exist.

So if the water wasn't the result of comets being blasted apart as they passed by, scientists wondered, where did it come from?

The water vapor sits in a dusty cloud surrounding IRC+10216. Scientists deduced that ultraviolet light from surrounding stars had penetrated that dusty cloud, breaking up molecules in it like carbon monoxide and silicon monoxide, which in turn released oxygen atoms.

Those oxygen atoms attached themselves to hydrogen molecules, forming water.

"The ultraviolet light didn't create it -- it helped it to be formed," Pilbratt told CNN.

Ultraviolet light is the only way water could have been produced in such conditions, he said.

IRC+10216 is a red giant star, hundreds of times the sun's size, the European Space Agency said. If it replaced the sun in our solar system, it would extend beyond the orbit of Mars.

The star is barely detectable at visible wavelengths because of that huge cloud of dust surrounding it. It can be seen at some infrared wavelengths, however, because the dust cloud absorbs almost all of the star's visible radiation and re-emits it as infrared light.

Scientists now hope to observe other carbon stars. "We are very hopeful that Herschel will find the same situations around those stars too," Decin said.