Weakened by a curse the irritable sage Durvasa placed on Indra after the god carelessly disrespected a garland the sage had offered him, the devas find themselves losing ground to the asuras and appeal to Vishnu for help. Vishnu counsels an unlikely alliance: churn the cosmic Ocean of Milk together, promising the treasures and the nectar of immortality, amrita, hidden within it to both sides, then find a way to keep the results for the devas alone. Using the mountain Mandara, uprooted and set upright in the ocean as the churning rod, and the great serpent Vasuki, wound around it as the churning rope, with the devas pulling at his tail and the asuras at his many-headed end, the two sides begin to churn the ocean between them.
As the churning intensifies, Mandara begins to sink for lack of a base, so Vishnu descends in the form of the great tortoise Kurma and positions himself beneath the mountain, bearing its full weight on his shell so the churning can continue. The strain first produces not treasure but poison: the deadly Halahala rises from the depths, threatening to destroy gods, demons, and the world alike with its fumes, until Shiva swallows it to protect creation, holding it forever in his throat rather than letting it pass further, which turns his throat permanently blue and gives him the name Nilakantha, the blue-throated one.