Once, while Parvathi was meditating under a mango tree, Lord Shiva decided to test her devotion. He set fire to the tree. Parvathi called out for help, and Vaamanar responded. Vaamanar, holding a conch and a discus in his four hands, removed the moon from Shiva's head and used its cool rays to extinguish the fire and revive the mango tree.
Later, Shiva sent the river Ganga to disrupt Parvathi's meditation. Despite Parvathi explaining that they were sisters, Ganga continued her course. In response, Parvathi embraced a sand Lingam, and both she and Shiva merged into it, thwarting Ganga's attempts to disrupt the meditation.
Because Vishnu helped Parvathi by removing the moon from Shiva's head, this temple is called "Thiru Nilathingal Thundam," and Vishnu is worshipped as "Nila thingal thundathan," meaning the one who held the moon.