Once King Sagar – the ruler of Ayodhya and an ancestor of Lord Rama successfully performed the Ashwamedha Yagya for 99 times. Each time, he sent the horse around the earth it returned to the kingdom unchallenged. However, Indra – the King of God’s became jealous of King Sagar’s success. So when King Sagar performed the sacrifice of the 100th time, Indra kidnapped and hid the Yagya horse in the hermitage of Kapila Muni
In search of the horse, sixty thousand princes from Ayodhya reached Kapil Muni’s hermitage. They mistook the sage to be the abductor and attacked him. An enraged Kapila Muni burnt the 60,000 princes to ashes. On hearing about the plight of his father and uncles, King Bhagiratha – one of the grandchildren of King Sagar requested Kapila Muni to grant a solution to the problem. Kapila Muni advised that the waters of the river Ganga would miraculously bring back the dead princes to life.
King Bhagirath left his kingdom and began to mediate for the salvation of the souls of his ancestors. It is said that Bhagirath observed a penance to Brahma for a thousand years, requesting Ganga to come down to earth from heaven and wash over his ancestor’s ashes to release them from a curse and allow them to go to heaven. Pleased with the devotion, Brahma granted Bhagirath’s wish but told him to pray to Lord Shiva, as he alone could sustain the weight of her descent.
Accordingly, Lord Shiva held out his thick matted hair to catch the river as she descended. The meandering through Shiva’s lock softened Ganga’s journey to the earth and the holy waters of river Ganga thus washed away the ashes of Bhagirath’s ancestors. A modified version of the legend says, what reached the earth were just sprinkles from Lord Shiva’s hair. The Ganga, thus, became an attribute of Shiva. This manifestation of Shiva is known as Gangadhara.
The legend is re-enacted by devotees of Lord Shiva as they give a bath to the linga during worship. And for this reason, many devotees prefer to take a dip in the holy water of river Ganga on a Shivaratri day.