Andhaka was the third son of Shiva and Parvati. A legend behind his birth says that once Parvati closed Shiva's eyes with her delicate hands and at once a darkness engulfed the world. The hands of the goddess were drenched in Shiva's fluid born of passion, and when this was heated by the heat of Shiva's third eye it grew into a horrific child, a demon, blind and gruesome. But Parvati, true to her nature, lovingly cared for this child as well.
After birth, Andhaka was given to Hiranyaksha to be raised, as he had no sons. Later, Andhaka became the king of Hiranyaksha's kingdom.
Shortly after becoming king Andhaka discovered that his cousins were plotting to overthrow him, so he retreated to the forest to meditate. He fasted and stood upon one leg for more than one million years, chopping off parts of his body as a sacrifice to Brahma as he waited.
Brahma then duly appeared and Andhaka asked that he be allowed to see, and become immortal — to be able to be killed by no-one. Brahma agreed so long as Andhaka named the circumstances of his own death, to which Andhaka said he would die if he ever chose to marry a woman who is like a mother to him.
Andhaka returned to his kingdom and quickly calmed the problems with his cousins.
Some millions of years later, three of Andhaka's generals (Duryodhana [This is not the Duryodhana from the Mahabharata], Vighasa and Hasti) happened upon Shiva and his wife Parvati in a cave, but did not recognise them. They thought that the woman beautiful enough for their king, and so hurried back to tell him the good news.
Andhaka asked them to return and ask for the woman in marriage. Shiva refused and Andhaka rushed to the cave to do battle.