As the Aitareya Brahmana tells it
Aitareya Brahmana 7.13 to 7.18 · 4 min read
King Harishchandra had a hundred wives and not one son.
The sage Narada was living in his house, and the king asked him what a man gains from a son. A son, said Narada, is a light in the highest heaven. Then he gave the king some advice.
"Go to King Varuna. Say to him: let a son be born to me, and I will sacrifice him to you."
Harishchandra did. "So be it," said Varuna. A son was born, and they named him Rohita.
Varuna came at once. "You have your son. Now sacrifice him to me."
"A victim is not fit until it is ten days old," said the king. "Let him pass ten days."
After ten days Varuna came back, and the king said, "Wait until his teeth come." When the teeth came he said, "Wait until they fall out," and after that, "Wait until they grow again." Then he said, "He is a warrior's son. He is not fit until he can bear arms."
Each time Varuna said, "So be it." Rohita grew up and took his arms, and Varuna came once more. The king called his son and told him the truth.
"No," said Rohita. He took his bow and went into the wilderness.
Then Varuna seized the king, and his belly swelled up.
Rohita heard of it in the forest and turned for home. On the road a Brahmin stopped him. It was Indra in a man's shape. "Good fortune goes with the one who keeps moving," he said. "Wander on." Rohita wandered another year, and when he turned homeward the stranger was there again with the same advice. This happened five times.
In the sixth year Rohita met a seer named Ajigarta, who was starving in the forest with his wife and three sons.
"I will give you a hundred cows for one of these boys," said Rohita, "to buy myself free."
The father held on to the eldest and said, "Not this one." The mother held on to the youngest and said the same. So they agreed on the middle son, whose name was Shunahshepa.
Rohita brought him home, and Varuna accepted the exchange. "A Brahmin is worth more than a warrior," he said.
Four great seers were the priests, Vishvamitra and Vasishtha among them. But when the boy was led up, nobody was willing to tie him to the post.
"Give me another hundred cows," said Ajigarta, "and I will tie him." They gave them, and he tied his son.
Nobody was willing to kill him either.
"Give me another hundred," said Ajigarta, "and I will do that too." He came forward sharpening his knife.
Shunahshepa thought, "They are going to slaughter me as if I were not a man at all. I will turn to the gods."
He called first on Prajapati, who sent him to Agni, and Agni sent him to Savitr. Savitr said, "It is for King Varuna that you are bound. Go to him." So the boy praised Varuna in thirty-one verses and begged him to loosen the rope above, the rope between and the rope below. Varuna sent him on again, and so did the others he praised. Last of all the boy sang three verses to Ushas, the Dawn.
As he sang those verses the ropes fell away one by one, and the king's belly grew smaller. At the last verse Shunahshepa was free, and Harishchandra was well.
He went and sat on Vishvamitra's lap.
"Give me back my son," said Ajigarta.
"No," said Vishvamitra. "The gods have given him to me."
Ajigarta pleaded with the boy himself and offered him all three hundred cows.
"They saw you with the knife in your hand," said Shunahshepa. "You chose three hundred cows over me. A man who does such a thing once will do it again."
So Vishvamitra adopted him, named him Devarata, "god-given", and set him above his own hundred and one sons. The fifty elder ones would not accept it, and their father cursed their children to live at the edges of the earth. The younger ones, led by Madhuchhandas, accepted their new brother, and those he blessed.
As the Ramayana tells it: the uncle at Pushkar
Valmiki Ramayana, Bala Kanda · 2 min read
The Ramayana tells of Shunahshepa while it is telling the life of Vishvamitra, and it knows nothing of a promise to Varuna.
King Ambarisha of Ayodhya was in the middle of a sacrifice when Indra carried off the victim. The priest was stern about it. "This is your carelessness. Find the animal, or bring a man in its place, or the rite is ruined."
The king searched through many countries, offering thousands of cows. At last, on a mountain called Bhrigutunga, he found the sage Richika sitting with his wife and sons, and asked for one of the boys.
"I will not sell my eldest for any price," said Richika.
"And I will not give up my youngest," said the mother. "A father loves the eldest best, and a mother the last."
The middle son spoke for himself. "My father keeps the eldest and my mother keeps the youngest. Then I am the one who is sold. Take me, king."
Ambarisha put him in his chariot and drove off. At noon they rested by the lake at Pushkar. There Shunahshepa saw his uncle Vishvamitra sitting among the hermits. He ran to him, worn out with heat and thirst, and fell against him in tears.
"I have no father now and no mother. Save me. Let the king's rite be finished, and let me live."
Vishvamitra turned to his own sons. "This boy has come to me for shelter. Go in his place, and let the rite be completed."
They laughed at him. "You would save another man's son and give up your own? That is like eating your own flesh." Vishvamitra cursed them in his anger. Then he taught the boy two hymns.
"When they bind you to the post, with the red garland on you, sing these to Agni and to Indra."
Shunahshepa learnt them and went back to the king. "Let us go quickly," he said. At the sacrifice he was dressed in red and tied to the post, and he sang. Indra was pleased and granted him long life, and the king gained the whole fruit of his rite all the same.