Ahalya was the beautiful wife of Gautam Rishi. The Sun and Moon were besotted by her beauty. Even though they had traversed the world every day they had not seen a more beautiful woman. She had been pious and devoted in her life (had done Bhakti) which is why her nails, hands and arms were all golden. The sun and moon were so desirous of Ahalya that they decided to seduce her. They began to observe the routine habits of her husband. They noted that Gautam Rishi woke up every morning when the cock crowed and went immediately to bathe in the river Ganga. So the Sun and Moon imitated the call of the bird in the night and as was his routine, the Rishi woke up, took his towel and left for the river. The Sun abused Ahalya and the Moon seduced Anjani (Rishi’s and Ahalya’s daughter). No one heard their cry for help.
When he reached, the river Ganga was not ready to meet him. She asked why he had arrived in the night when his usual time was later at 5 am. He told her he always followed the call of the bird. She cautioned him, suspecting that someone was out to cheat him and suggested he return home quickly, but Gautam Rishi insisted he must take his bath. As she was not quite ready she said she would turn her back and he could soak his towel in the water and wipe himself in lieu of a bath. Gautam Rishi did this and then left for home.
When Gautam Rishi returned he saw that the Sun and Moon were indeed with his wife Ahalya and daughter Anjani. The sun escaped as soon as he saw the rishi but the moon was slow and Gautam Rishi managed to hit him with his wet towel, (causing the dark marks on the moon). He cursed his wife Ahalya telling her that she would turn to stone on the banks of the Ganga in Haridwar for 12 years. Only when Lord Vishnu visits the Kumbh mela will she turn back into a human. Till then she will be a stone on which people will come to bathe, wash clothes, walk over her and subject her to all humiliation which she will suffer in silence because she will be speechless. To his daughter he said she will be an unwed mother and will give birth to a boy. Ahalya was so angry with her husband for doubting her, that she did not offer any explanation and kept quiet. Anjani, buried half of her body in the earth and did not come out for months hoping that this way she could avoid giving birth to a child. But Gautam Rishi’s word was sacred so a child was born from her ear.
This child came to be known as Pavan Putra Hanuman. When Vishnu visited the Kumbha Mela after 12 years his foot accidentally hit a stone that was Ahalya and she came back into her human form. She was then returned to her husband.