The first written evidence of the Kumbha Mela can be found in the accounts of Chinese monk Xuanzang (alternately Hsuan Tsang) who visited India in 629-645 CE, during the reign of King Harshavardhana. However, similar observances date back many centuries, where the river festivals first started getting organized. According to medieval Hindu theology, its origin is found in one of the most popular medieval puranas, the Bhagavata Purana. The Samudra manthan episode (Churning of the ocean of milk), is mentioned in the Bhagavata Purana, Vishnu Purana, the Mahabharata, and the Ramayana.
The account goes that the Devas had lost their strength by the curse of Durvasa Muni, and to regain it, they approached Lord Brahma and Lord Shiva. They directed all the demigods to Lord Vishnu (full story on kumbh mela) and after praying to Lord Vishnu, he instructed them to churn the milk ocean, Ksheera Sagara (primordial ocean of milk) to receive amrita (the nectar of immortality). This required them to make a temporary agreement with their arch enemies, the Asuras, to work together with a promise of sharing the wealth equally thereafter. For the task of churning the milk ocean, the Mandara Mountain was used as the churning rod, and Vasuki, the king of serpents, became the rope for churning. They churned the ocean for 1000 years, where demons were holding Vasuki's head and Gods were holding its tail. Finally after this entire churning process, Dhanwantari appeared with Kumbh in his palms.
However , when the Kumbha containing the amrita appeared, a fight ensued. To prevent the amrita (elixir of immortality) from demons, its safety was entrusted to Gods Brahaspati, Surya, Shani and Chandra. After learning the conspiracy of the Devtas, demons turned vicious and attacked them. Devtas knew that demons possessed more power and can easily defeat them. The Devtas ran away with the Kumbh to hide it away and they were chased by Asuras. For twelve days and twelve nights (equivalent to twelve human years) the Devas and Asuras fought in the sky for the pot of amrita. It is believed that during the battle, the drops of amrita fell down from Kumbh at four places: Allahabad (Prayag), Haridwar, Ujjain and Nashik. Because 12 days of Gods are equivalent to 12 years for humans; the Kumbh Mela is celebrated once every 12 years in each of the four places - banks of river Godavari in Nasik, river shipra in Ujjain, river Ganges in Haridwar, and at the Sangam of Ganges, Yamuna, and Saraswati in Allahabad, where the drops are believed to have fallen. It is believed that the river turns itself into sanctity spots filled with primordial amrita at the.