In the Mahabharat,there was a snake and he was also a friend of Lord Indra and he was defeated in the Mahabharata war and his name was "Takshak". So,who is he and what is his story?
The story of Takshaka is mentioned in Shrimad Bhagavatam. It goes like below:
Parīkṣit, who was the grandson of Arjuna, having listened to the Bhāgavatam, had attained the transcendental position of fearlessness and oneness with the Supreme. Thus, Parīkṣit, free of all doubts, sat down in yogic posture and merged himself in meditation upon the Supersoul.
Then the snake-bird Takṣaka, arriving in the disguise of a brāhmaṇa, bit him, and the body of the saintly king immediately burned to ashes.
This means, Takṣaka was responsible for slaying Parīkṣit.
Actually, Parīkṣit himself was cursed by a sage's son to die by a snake bite. Takshaka came to fulfil the curse. Takshaka did the deed by approaching in disguise.
Later King Janamejaya, the son of Parikshit, become angry and fought a war with nagas.
Janamejaya, the son of Parīkṣit, became very angry when he received news of his father’s death, and he began a sacrificial performance for the purpose of destroying all the snakes.
Even though Takṣaka received protection from Indra, he nevertheless became attracted by the mantras and was about to fall into the fire. Seeing this, Bṛhaspati, the son of Aṅgirā Ṛṣi, came and advised Janamejaya that Takṣaka could not be killed because he had drunk the nectar of the demigods.
Janamejaya was thus convinced by the words of Bṛhaspati and stopped his sacrifice.
Takshaka later became a robber, waiting to loot anything valuable from the travellers traversing through his domain.
Later, when Janamejaya started a campaign with the view of exterminating the Naga race Takshaka left his territory and escaped to the Deva territory where he sought protection from Deva king Indra.
But Janamejaya's men traced him and brought him as a prisoner, to execute him along with the other Naga chiefs. At that time, a learned sage named Astika, a boy in age, came and interfered. Janamejaya had to listen to the words of the learned Astika and set Takshaka free. From then onwards the Nagas and Kurus lived in peace.