Once sage Durvāsā went out travelling across the world, and he met Indra. Durvāsā had in possession a divine garland of Pārijāta flower (or Santānaka flower) which he received from God Viṣṇu (in another opinion, from an Apsarā). Durvāsā gave the garland to Indra, which he took and placed on the head of Airāvata. The elephant got annoyed with the smell of the flower, and lifted it with its trunk, and threw it away. Feeling insulted, sage Durvāsa angrily said to Indra — “Eulogic hymns offered  by such sages as Gautama and Vaśiṣṭha, psychofancy of human beings and the uncomparable wealth of the heavenly abode have made you so proud, that you have dishonoured this garland which is blessed by God Śrī Hari, and insulted me as well. As a result of this, the entire heavenly abode will be deprived of Śrī.

Soon, as a result of Durvāsā̍s curse, the realm of gods began to be out of grace and glory. All the wealth of svarga began to decline, all beauties faded away, even the trees were becoming lifeless. Several vices were found in the characters of the gods, they got prone to sins. They looked like weak old men without energy and enthusiasm.

On this opportunity the Asura(s) attacked heaven, the weak gods were defeated. Many soldiers in the gods̍ army were dead. As per the advice of Brahmā, gods went to Vaikuṇṭha to Śrī Hari, and prayed for getting back their lost wealth, energy and glory. Śrī Hari said, if the gods could get amṛta by churning of the ocean, they could get back their strength and energy. For the accomplishment of this act, the gods should come to a compromise with the Asura(s), and it should be proposed that the wealth and amṛta got out of the churning of the ocean would be equally distributed among the gods and the Asura(s).–
devairasurasanghaiśca mathyatāṃ kalaśodhadhiḥ
bhaviṣyatyamṛtaṃ tatra mathyamāne mahodadhau.

However, God Viṣṇu assured the gods that it would be only a proposal of alliance. Actually the gods will be beniffitted, and the Asura(s) will suffer as a consequence of this. The gods agreed.

In Matsyapurāṇa, it is said that gods were not immortal earlier. But Sukrācārya, guru of the Asura(s), pleased Mahādeva and recieved the sanjīvanī mantra, by the grace of which he could rejuvenate the dead Asura warriors. So the Asura(s) were free of the fear of death. They attacked the gods very often, and many god-soldiers died in these battles between gods and demons. The god-army ḍbegan to decline, and the gods, being afraid, sought the help of God Nārāyaṇa. Nārāyaṇa advised them to get amṛta by the churning of the ocean, so that drinking the amṛta, gods could be immortal.

As per the advice of Nārāyaṇa, the gods, bearing the proposal of forming an alliance, went to the court of the demon-king Vali. Pleased with the nice words of Indra, Vali was pleased and agreed. Now the gods and demons jointly took the initiative for the churning of the ocean. The great mountain Mandara was used as the churning pole. The gods and demons tried hard to lift the mountain and place it by the sea, but the failed. then, as per the order of Nārāyaṇa, Ananta, the king of Nāga(s) (or Garuḍa, in another version), luprooted it and placed in the sea.

Then the gods and demons made Mandara-parvata their churning pole, and made Ananta Nāga (or Vāsuki Nāga) the rope for churning, and started Samudramanthana. But after some time, Mandara parvata started sinking due to its heaviness. Then, in order to lift it up and hold it steadfast, Nārāyaṇa assumed the form of a great kūrma or tortoise. Then the gods took the tail of the Nāga, and the demons took its upper portion. During the churning, the sea was terribly disturbed, several water-creatures died. Extracts from the juice of plants of the mountain, the gold-substance melted away from its body– all these got mixed with the the salty water of the sea, and coming in contact with that water, the gods attained immortality. The salty sea-water, mixed up with extracts from the plants and herbs, produced milk and ghee.

The churning of the sea continued for a long time, and from the sea, emerged several riches. From the sea, emerged Kāmadhenu, and she resided in Brahmaloka as Homadhenu. Then emerged the horse Ucchaiḥśravā, the eight dighastī(s) like Airāvata, and their eight wives, Abhramū and others. They added to the glory of the heavenly abode and Indra, the king of gods. Then the hoghly expensive padmarāgamaṇi called Kaustabha, which Nārāyaṇa held in his necklace. Then emerged the terrible venom called halāhala. Vāsuki Nāga was no longer able to bear the strain of the churning. So the Kālakūṭa poison came out of his mouth–
atinirmathanādeva kālakūṭastathāparaḥ.

The entire world was about to be destroyed by the virulence of this poison. Then, at the request of gods, Mahādeva took that poison and held it in his throat, in order to save the world. Thus his throat turned blue, and he came to known as Nīlakaṇṭha. But according to other Purāṇa(s), it was said that during the Samudramanthana, what came at first was the Kālakūṭa poison. In Padmapurāṇa, it was described that at this time Alakṣmī came out. She started residing in the houses of people who are sinful and fond of quarrel. Alakṣmī accepted Uddālaka as her husband.

Finally Dhanvantari came out with a kalasa full of amṛta. When this amṛta emerged, the Asura(s), in order to have the full share of amṛta, took it from him and fled. Soon after, they started quarreling on the matters of serving amṛta, and who will take it first. Now, the gods became disappointed and frustrated, and went to God Nārāyaṇa.

In order to restore the container from the quarreling Asura(s), ŚrīHari assumed the shape of a beautiful woman, and came in front of the Asura(s). His Mohinī form easily attracted the Asura(s). Charmed by that beautiful woman, the Asura(s),the Asura(s), entrusted the container of amṛta into her hands, and wished that she would disribute it. Hearing this proposal, Mohinī smiled and said, “Whether my action is fair or unfair, if you don̍t protest, I can take the responsibility of distributing amṛta. The Asura(s) agreed .

Then the gods and the Asura(s) sat down in separate rows, in a beautifully decorated courtroom. Śrī Hari, in the shape of Mohinī entered there. She did not consider the cruel Asura(s) worthy of having the amṛta. She kept the Asura(s) charmed by her nice behaviour and served amṛta only to the gods. The Asura(s) got so much bewitched by her beauty that they did not protest, in fear of losing her ̍love̍. But the Asura called Rāhu noticed this deception, and assuming the form of a god, sat amongst them. When Rāhu drank the amṛta, Candra and Sūrya identified him and disclosed the fact. Before the amṛta could reach his throat, God Viṣṇu̍s Sudarśana cakra cut his head off. His body, without being drenched with amṛta, fell on the ground, but Rāhu̍s head, due to drinking amṛta, attained immortality. After the god̍s amṛta-drinking was over, God Viṣṇu came back to his own self. After that, another battle broke out between the gods and the Asura(s). But by the grace of amṛta, the gods became immortal and so powerful that their victory was easy. Entrusting the safety of amṛta to Viṣṇu himself (Kirīṭi) and some other powerful gods, the rest of the gods went back to their heavenly abode.

Rāhu blamed Candra and Sūrya for his situation, and so, even today the Rāhu graha (planet) sometimes devour Candra and Sūrya. But since his body is without torso, the Sun and the Moon get released after some time. In this way, Purāṇa(s) have given explanation to the solar and lunar eclipse.