Asamañja (Asamanja)was the eldest son of Sagara, a king belonging to Ikṣvākuvaṃśa (Ikshwakuvamsa; the Ikshwaku dynasty). In  Mahābhārata (Mahabharata), king Sagara, along with his two wives, worshiped Mahādeva (Mahadeva), in order to get the boon of having a son. Please with their tapasyā (tapasya; ascetic penance), Mahādeva said, “The moment in which you have asked for the boon, because of that moment, you will have sixty thousand sons together, out of the womb of one of your wives. And later, all of them will be destroyed together. On the other hand, another son, who will be valiant, and the protector of the genealogical line — will be born of the womb of your second wife”. By the grace of Mahādeva, Sagara’s queen Śaivyā (Saivya) gave birth to a son called Asamañja.

According to Purāṇa (Purana; Mythological Scripture), Asamañja was born of the womb of Sagara’s wife, Keśinī (Kesini). Pleased with the hospitality offered by the two wives of Sagara, Maharṣi (Maharshi; GreatAurva blessed him with the boon of having sons. By the blessing of Aurva, Keśinī got Asamañja as her son.

According to Mahābhārata and most of the Purāṇa(s), Asamañja was very cruel and tyrannical. He used to kill young basies, drowning them in water. The subjects complained to the king against the prince and the king abandoned him.

However, in Brahmāṇḍapuraṇa, the cause behind this cruelty of Asamañja has been described. From Brahmāṇḍapurāṇa it is known that Asamañja was not at all cruel since his childhood, rather he expressed intelligence and good qualities. But due to the deeds done in previous birth, one day he fell under the spell of a Piśāca. In his previous birth, Asamañja was born in a Vaiśya family. One day he discovered a huge treasure inside a forest. The Vaiśya sought to take the treasure home. A Piśāca was there, protecting that treasure. he told the Vaiśya. “I have been looking after this treasure for a long time. So I am very hungry. If you satisfy my hunger with beaf, I shall give you this treasure.” The cunning Vaiśya said, “Let me go home with this treasure. After that I̍ll of course bring your food.” The simple Piśāca believed him and let him go. But the Vaiśya never came back. The Piśāca, tired of waiting, died of extreme hunger. After death, the spirit of that Piśāca roamed about in search of that Vaiśya. The Vaiśya also died in course of time, and in the next birth, he bacame Asamañja, the son of king Sagara. The Piśāca recognised him, and possessed him. So the prince Asamañja was being controlled by the Piśāca. People suffered and got annoyed due to his arrogant and atrocious behaviour.

In a famous royal dynasty like the Ikṣvāku clan, the birth of a cruel person like Asamañja was really a matter of shame. Perhaps the composers of Purāṇa, considering the noble, sage-like kings of the Ikṣvāku clan, have sought to give a reason behind this behaviour of Asamañja, and invented the story of this Piśāca.

In Bhāgavatapurāṇa, the character of Asamañja has been described in a different way.

According to Bhāgavatapurāṇa, Asamañja was a great Yogī in his previous birth. But falling into evil associations, he departed from the path of Yoga. But the memory of the previous birth did not leave him. When king Sagara ordered him to be exiled, as a punishment for drowning little children in water, Asamañja brought them back to life using his Yogic power. The he left the kigdom and went away to the woods.

Asamañja was the father of Rājarṣi Angśumāna. According to Mahābhārata and most of the Purāṇa(s), after king Sagara, his grandson Angśumāna became the king. However, in some places, it has been mentioned that when sage Kapila burned to death the sixty thousand sons of Sagara, five of them were spared. Pañcajana or Pañcavana was one of them, who later became the king. But in Harivaṃśa Purāṇa,it is clearly mentioned that Asamañja came to be known as Pañcajana and after Sagara, he bacame the king–
ekaḥ pañajano nāma putro rājā vabhūva ha
sutaḥ pañcajanasyāsīdaṃśumān nāma vīryavān.

From this, it appears that Asamañja̍s character got rectified in later curse and he exhibited good qualities, so king Sagara brought back the exiled son and nominated him the successor to his throne.