An astrologer told a Pandya King that he was destined to die from a cobra bite on a particular day. He was advised to go and pray before Lord Guruvayurappan. He spent years in meditation and prayer at the feet of the Lord. Suddenly the King realised that the time allotted for his death had passed. He came back to his palace and asked the astrologer as to how his prediction had gone wrong. The wiseman showed him the mark on his left foot where the cobra had bitten him. Since he was wholly absorbed in the Lord, Who alone can dispense with fate, he did not feel the sting. In gratitude, the King built the temple at Guruvayur and set apart funds for the daily routine of the temple. Most parts of the temple, as it is today, are of the 16th and 17th centuries. At later periods and different stages, extensions to the temple were made by rich devotees. The deepastamba (column of lights) was erected in 1836 by a devotee from Thiruvanathapuram. The temple has gopurams in the east and the west. The eastern gopuram has an inscription which refers to the town as "Gurupavanapura". The western gopuram was built in 1747.