In ancient times there was a king named Sagar who had two queens named Keshini and Sumati, Sumati had sixty thousand and Keshini had one son. Once King Sagara performed Ashwamedha Yagya. In order to break the yagya, Devraj Indra stole the horse left by the king and tied it in the ashram of Kapil Muni.The king sent his sixty thousand sons in search of the horse for the sacrifice. While looking for the horse, all the sons reached Kapil Muni's ashram, seeing the horse tied there, Kapil started calling Muni a thief and hypocrite and also abusing him.
At that time Kapil Muni was engrossed in meditation, Kapil Muni's samadhi was broken due to the king's sons and all the sons of the king were burnt to ashes in the anger of Kapil Muni. When there was no information of any son even after a long time, after getting the permission of the father, Anshuman reached the sage's hermitage while searching for his brothers.
There he met Garud, who witnessed the whole incident himself and narrated the whole story of his brothers being consumed by Anshuman. Garudji also told Anshuman that if you want his salvation, then Gangaji will have to be brought from heaven to earth. But first complete your father's yagya, then do the work of bringing Goddess Ganga to earth, only through Goddess Ganga can the souls of all your brothers be liberated.
Anshuman reached the Yagya Mandap with the horse and narrated the whole story to King Sagara. For the peace of the soul of his brothers, Anshuman did penance to bring Goddess Ganga to earth, but he failed. After the death of Anshuman, his son was Dilip, Dilip also did penance to bring Goddess Ganga to earth but he also did not get success.
Finally, Dilip's son Bhagirath went to the Gokarna shrine and did severe penance to please Brahma. After many years, Brahmaji, pleased with Bhagirath's penance, granted a boon to take Gangaji to the earth. Now the problem was that after the release of Brahmaji from the kamandal, no one on earth has this power to handle the velocity of the Ganges. Brahmaji told that only Lord Shankar is in the earth, who can handle the velocity of Goddess Ganga. That's why you pray to Lord Shiva.
Bhagiratha started worshiping Lord Shankar by standing on one thumb. Pleased together with his severe penance, Shiva agreed to handle Ganga in his hair. When Goddess Ganga moved from the kamandal of Brahma to the earth, Shiva covered the stream of Ganga in his hair.
For many years, Ganga could not come out of Shiva's hair, then Bhagirath requested Shiva to free Goddess Ganga from the hair. After this, Shiva untied his locks and Goddess Ganga was moving towards the plain after coming out of the locks in the Himalayan valleys, on the same path was the ashram of sage Jun.
The noise of the Ganges was disturbing the penance of Sage Jun, due to which Sage Jun drank the Ganges in anger. On the request of Bhagirath, she was again removed from the thigh, since then Ganga came to be called Jahnavi or Jahuputri.Crossing many places, the Ganges reached Kapil Muni's ashram and freed the ashes of Sagara's sixty thousand sons. Brahma ji blessed Bhagirath's hard penance that Gangaji's name will be Bhagirathi in your name.