Sri Naradiya Purana mentions how Janamejaya was cured of leprosy by taking refuge under the feet of Guruvayuruppan. The Pandavas handed over the kingdom to their grandson Parikshit, and left for the forest to spend their last days. Parikshit died of the curse of a saint, who cursed that Parikshit will die of snake bite by Takshaka, the king of serpents. After the death of Parikshit he was succeeded by his son Janamejaya. Janamejaya conducted a sacrifice to destroy all the snakes of the world including Takshaka, who was the cause of his father’s death . Hundreds of thousands of snakes fell into the sacrificial fire and were killed, but the sacrifice was stopped by a Brahmin called Astika, before Takshaka was killed.
According to legends, the deity worshipped here is more than 5000 years old. In the 14th century, “Kokasandesam” (a Tamil literary work), references to a place called Kuruvayur are made. As early as the 16th century (fifty years after Narayaniyam was composed) many references to Kuruvayur are seen. In ancient Dravidian languages, “kuruvai” means “sea”, hence the village on the Malabar Coast may be called Kuruvayur. The earliest temple records date back to the 17th century. The earliest mention of the many important Vishnu temples of Kerala are found in the songs of Alwars, Tamil saints, whose time-line is not exactly fixed. Mamankam was a very famous local event at Tirunavaya, on the bank of Bharatappuzha. The battles between the Kozhikode under Samoothiris and Valluvanad popularised Guruvayur Temple. Due to the prolonged battles, people across the riverbank started preferring Guruvayur. Even the Samoothiri of Kozhikode become a devotee and thus his subjects followed him. The central shrine that is seen today is said to have been rebuilt in 1638 AD. “Viswabali” was performed later to propitiate all the spirits, good and bad. By the end of the 16th century Guruvayur had become the most popular pilgrimage centre in Kerala.