According to an old legend, two hundred years ago, a couple named muthuraiyar community Valliammal and Periyasamy were travelling from Karur to Madurai. As it got dark on the way to Madurai, they decided to stay at Melamadai near the present Mattuthavani and slept there. At night, a long-bearded sage appeared in Valliammal's dream and told him that he was Pandyan Nedunchezhiyan, the ruler of Madurai, and that he had been meditating in the same place, eight feet deep in the earth as a penance for the injustice he did for Kovalan, the husband of Kannagi by taking rebirth. He further added that, if they worship him, then he would protect and bless their family. A startled Valliammal told her husband what had happened and they unearthed the idol buried eight feet deep in the soil. After that, a temple was built on the site and the community of Valliammal continues to worship and maintain this temple till today.[1]