Though the main story about the idol is just starting since the story of Lord Krishna, its antiquity goes long back, since it is believed to have constructed by Lord Vishnu himself. The story is told in detail in the section 'Gurupavanapura Mahatmyam' from Narada Purana. King Parikshit, the grandson of Arjuna and the son of Abhimanyu, died of a bite by the poisonous snake Takshaka, due to a curse which fell upon him. King Janamejaya, his son, wanted to avenge his father's death by killing all the snakes, including Takshaka, and for that, he conducted a fierce yajna called 'Sarpastra' (Snake sacrifice). Thousands of innocent snakes died in the yajna fire, but Takshaka could not be killed because he had drank amrit. Due to this act, Janamejaya was affected by the curse of snakes, and got affected by leprosy. He tried numerous ways to cure his disease, but none of them worked. He lost his hope to live. At that time, sage Atreya (the son of sage Atri) came to visit him and told him to worship Lord Mahavishnu in Guruvayur. He then also told the glory of the temple. It is as follows: