According to the Brahmanda Purana the story of this temple is revealed. In Karnataka there was a sage named Divakar. Every day he worshiped the Supreme Lord. One day his beloved Lord disguised Himself as a very beautiful boy. He attracted the heart of Divakar like no one else. Every day that little boy came and Divakar’s love was growing. One day this little child told him “I have no father, mother and no place of residence. I am just all alone wandering.” Divakar said to the small child “I will take care of you, stay with me”. The child said “I will stay with you if you promise me that you will never chastise me for anything I do. If you chastise me I will leave.” Divakar said, “I promise that I will never chastise you.”
This boy was very naughty. But Divakar was in ecstasy by seeing the naughtiness due to his love for him. But the child really tested him. One day Divakar was doing worship and he was alarmed to see that his ‘saligram sila’ was missing. He was searching and he found that the little boy was sucking the saligram. Divakar immediately chastised Him. The child told Divakar that since he has violated his promise, He will now leave.
Saying those words,the child ran away and Divakar ran after him. As the boy was running, His waist bells and ankle bells were tinkling. Divakar’s heart was charmed; he could not live without the child. The child told him, “If you ever want to see me again you should look for me in the Ananta forest.” Then the child disappeared.
Divakar was searching everywhere; he spent rest of his life looking for this Ananta forest. He had never heard of such a place. He was walking and asking everyone. He came all the way down to southern part of Kerala, which is today Thiruvananthapuram. He came to a village where a very simple tribal woman was chastising her son, “You are so naughty. Next time if you do this, I am going to throw you into the Ananta forest.” When Divakar heard that he became very enlivened. He was a saint, a sannyasi and he approached this lady and said, “I will give you all blessings but please tell me where is this Ananta forest?” Tribal lady told him how to get there.
The forest was very dark, Divakar had a single wick. He went into the forest searching for the child. Suddenly he heard the tinkling of the waist bells and the ankle bells. He went into ecstasy and started looking from where that sound was coming. Suddenly an Ilupa tree fell to the ground with a massive crash and from the tree, radiant effulgence blinded Divakar. When the effulgence flashed by, he saw the deity of Ananta Padmanabha was manifested from the tree.
The deity was very huge with head in one village, His feet were in another village and His waist was in the Ananta forest. According to the records, he was approximately 18 km long. Divakar took unripe mango and then he grabbed a coconut shell and made a little plate and put the salty mango in the coconut shell and offered it with love and devotion. Divakar requested the Lord to reduce in size so that he could worship Him and serve Him. Lord immediately accepted his prayers and reduced Himself in size. Divakar had a stick and the Lord reduced to three times the length of that stick. Till this day, naivedyam or offering prepared from rice is offered to the Deity here in a coconut shell.