An interesting story related to the origin of moon god is
found in the Matsya Purana. As per the legend, Chandra was the son of Sage Atri
and his wife Anasuya.
Legend has it that Brahma, the Hindu God of creation, once
deputed Sage Atri to create a unique world which is filled extraordinary
beings.
To fulfill the job, Sage Atri performed intense penance. One
day while he was meditating, an intense light emitted from the eyes of the
sage. The light took the form of a ball and it could not be controlled. Due to
it the day never came to an end. All the living beings were confused and there
was commotion in the universe.
Dikpalakas, the guardians of the eight corners of earth,
could not manage and keep the light in check. So they threw the ball of light
into the ocean.
Thousands of years later, when Devas and Asuras
performed the churning of ocean (Samudra Manthan), the ball of light came up
and it got a place in sky and was named Chandra, the moon god.