When Indra had to go into hiding after killing a Brahmin, the gods needed a temporary ruler for the heavens. They chose Nahusa - a king of such exceptional virtue and merit that he could serve as Indra.
Nahusa sat on Indra's throne. He ruled the heavens. He enjoyed the pleasures of the heavenly realm. And then, slowly, the pride began.
He began to think: I am greater than Indra. I earned this throne by my own virtue. I deserve the honors of the Lord of the Gods.
He demanded that Indra's wife Shachi come to him as his queen.
Shachi stalled him while she looked for Indra. The sage Brihaspati advised her: "Tell him he may come to you - but insist that he come in a palanquin carried by the seven sages. Delay him."
Nahusa, proud and impatient, commanded the seven rishis to carry his palanquin. They moved slowly. Nahusa kicked the rishi Agastya and shouted: "Move faster! Sarpa! Sarpa!" - meaning "move, move!" but also meaning "snake."
Agastya cursed him immediately: "Since you called me sarpa and treated the rishis as beasts - you will be a serpent yourself."
Nahusa fell from the heavens and lived as a great python for thousands of years, until Yudhishthira finally recognized and released him.