King Sagara was performing the Ashvamedha Yagna. But the sacrificial horse was stolen by Indra, the king of Gods. Sagara had 60,000 sons, and he sent them to search for the horse, for the yagna was incomplete without it.
Sagara’s sons reached Sage Kapila’s ashram, still searching for the horse. Indra had hidden it there, but the princes thought that the sage had stolen it. All of them started shouting at him, and the commotion distracted Sage Kapila from his long-meditation. He opened his eyes, which had been closed for many years, and with one glance, burnt all the 60,000 sons of Sagara to ashes.
The souls of these sixty thousand sons had not attained moksha, as their final rites had not been performed. Hence, they had no choice, but to roam the earth in the form of ghosts. Anshuman, their nephew, started penance to appease Brahma to bring the river Ganga down to the earth, so that the souls could be purified by her waters, and hence attain moksha.
But before he could get Brahma to respond to his penance, Anshuman died. His son, Dilip tried to continue this penance, but he also did not succeed. Then came one of King Sagara’s descendants, Bhagiratha. He learnt of the plight of Sagara’s sons, and vowed to please Brahma to bring Ganga down to the earth. He performed penance for many thousands of years, and finally when Lord Brahma was pleased, he asked Ganga to go down to the earth, and flow over the ashes of Sagara’s sons, so that they could attain moksha.
But Goddess Ganga felt insulted at Brahma’s order, and decided to fall onto the earth with tremendous force, so as to sweep the regions out. And she did so. The earth was flooded with angry Ganga’s waters. Bhagiratha was worried for his kingdom from Ganga’s floods, and prayed to Lord Shiva for help.
Shiva agreed to help Bhagiratha. He caught Ganga along with her waters in the locks of his matted hair, and tied them up, thus locking Ganga there. Then, he let her out in a gentle stream, and thus saved the earth from a great flood.
The touch of Shiva humbled Ganga’s arrogance, and she agreed to help Sagara’s sons. As per Lord Brahma’s orders, she flowed over their ashes, and all of them attained moksha, after several thousands of years.
The river Ganga is still known for this feature: the dead ones attaining moksha. Even now, many people immerse their dead loved ones’ ashes in the waters of Ganga for them to attain moksha. And it is believed that if one takes a dip in the Ganga, he or she will be free of all sins, and thus purified. Sadly, this very belief has been one of the major causes for the current level of pollution of the Ganga river. And it is also believed that the river will dry up with the end of this present Kali Yuga.