The gods appointed Angiras Vrihaspati as their priest and the demons (Asuras), not to be left behind, appointed Bhargav Shukracharya to be their guru. Now both these brahmin priests were stalwarts in their fields and enjoyed a healthy rivalry too. They respected each other immensely but also indulged in a game of one-up man ship.
The war between the gods and asuras had started in earnest and both the priests were busy with their Yajnas and prayers to make their sides more powerful. Shukracharya, the priest of the demons, would breathe life into the demons who died in the battle and make them healthy again. He could do so because he was an expert in the knowledge of Sanjeevani (the art of breathing life in a dead being). This Sanjeevani Vidya (knowledge) was making the asuras stronger and they were the obvious leaders in the fight, as they were not facing any casualties.
The gods on the other hand were suffering great losses, as Vrihaspati, their guru, did not possess the Sanjeevani Vidya. The gods and their guru deliberated on this drawback and decided that someone would have to go and learn this art of breathing life into a dead body from the guru of the demons.
It was decided that Kacha, the son of guru Vrihaspati, would go to the land of the demons to learn the Sanjeevani Vidya. Kacha went to Vrishparva, where Shukracharya had his Ashram (hermitage). He introduced himself to the great priest, "Sire, I am the grandson of Maharishi Angira and the son of Vrihaspati, the priest of gods. I implore you to accept me as your pupil. I promise to live the celibate life of a Brahmachari (student) and serve you for one thousand years."
Shukracharya was pleased with the humility of Kacha and accepted him as his pupil. He said, "I will treat you as if I am treating my friend Vrihaspati and I will be honoured to accept you as my pupil."
Kacha started his studies and would keep the guru happy with his behaviour. He would also take good care of the daughter of his guru, Devyani. Time passed and Kacha became Shukracharya's favourite pupil. After 500 years had passed, the demons learnt of the real purpose of Kacha's visit. They were incensed and feared that with the Sanjeevani Vidya, the gods would become more powerful. So they plotted to kill Kacha.
One day, when Kacha was grazing the cattle in the jungle, the demons killed him, cut him into small pieces and fed him to the wolves. In the evening the animals returned without Kacha. Devyani, who was by now deeply in love with Kacha, was worried and went to her father. She told him that Kacha was missing and that he must do something to get him back. She said, "I fear that someone has killed him or he is dead somewhere in the forest. Please use your knowledge to bring back my Kacha. I cannot live without him and shall die if he is not brought back from the dead." Shukracharya, who himself was fond of Kacha, used his powers and breathed life into Kacha. All the pieces of Kacha tore open the stomachs of the wolves and joined together and Kacha came alive. He returned to the hermitage and thanked his guru.
After a few days, the asuras again killed Kacha and on Devyani's request, Shukracharya again breathed life into him. The third time, the asuras killed Kacha, and burnt his body. They then took his ashes and mixed it with wine and requested Shukracharya to drink the wine. Shukracharya, who was unaware of the vile machinations of the asuras, drank the wine. When Kacha didn't return to the hermitage, Devyani again went to her father and requested him to bring Kacha back to life. Shukracharya started chanting the mantras which would bring Kacha to life. Kacha, who was inside the stomach of Shukracharya, revealed his dilemma from inside in a quiet voice. He said that he would not come out of the stomach of his guru, as that would mean killing his guru.
Shukracharya said, "Son, you are a great ascetic and very dear to me and my daughter. If you are not Indra, and if you are a Brahmin, then I shall teach you the Sanjeevani Vidya. And I know that you are not Indra, because only a brahmin could stay alive in my stomach for so long. Now, I shall teach you the secret knowledge of Sanjeevani so that you can come out of my stomach and then breathe life into me."
Kacha said, "I have lived in your stomach, so I am your son. You have breathed life into me and have taught me the art of Sanjeevani which is like the flow of Amrit (the divine ambrosia which gives eternal life) in my veins. I shall behave as a good son should do because those who do not respect their guru, who is like a god for a pupil, deserves to rot in hell."
Shukracharya, who was displeased with himself for drinking wine, which caused him to be irrational so that he could not see through the machinations of the asuras promised never to touch a drop of any intoxicants. He also laid out a rule for all the brahmins, that if they drink alcohol, they would be breaking divine rules and would deserve to rot in hell. They would not only spoil the good deeds of this life, they would also ruin their next birth, if they touched even a drop of wine.
After this, he asked Kacha to tear open his stomach and come out. Kacha did as he was told and when he came out the guru died. Kacha used his knowledge of Sanjeevani and breathed life into his guru, like a dutiful son should do. He then stayed with Shukracharya till the completion of his one thousand years and soon it was time for him to leave.
Devyani then approached him and told him of her love for him. She requested him to marry her according to the norms and take her with him. Kacha was now in a dilemma as he considered the daughter of his guru as his sister, as was the correct conduct for a rishikumar (son of a guru). He said, "Sister, as I have lived in the same stomach from which you were born too, I am your brother. Therefore, due to this reason, I am your brother, besides, you are the daughter of my guru, who is like a father to me. So I cannot marry you as you are my sister."
Devyani was hurt and angry at Kacha's refusal and she cursed him. She said that all the knowledge that he had acquired from her father would be of no use to him. Kacha replied that he accepted her curses as inadvertently he had hurt her, but he would teach others what he had learnt and then they would use it to the benefit of others. He also said that she had not considered that he was bound by the rules of conduct and had cursed him, therefore no Brahmin would marry her. He then took leave from his guru and went to the gods and his father where he used his knowledge for the benefit of others.