As per Hindu legend, a Pandya king Parakkirama Pandian wanted to construct a temple for Hindu god Shiva at Tenkasi and went to Kasi to bring a lingam, an iconic representation of Shiva in South India. Shiva appeared in his dream and asked him to follow the army of ants. The next day he found that there was an army of ants. The king realised that it was because of the divine intervention that he was prevented from going to Varanasi. He built the temple in the place where the anthill ended.