As per the Legends, Lord Muruga imprisoned Lord Brahma for His ignorance towards Pranava Mantra Om and assumed the role of the Brahma (Creator). Lord Vishnu requested Lord Siva to resolve the dispute. Lord Siva asked Murugan to release Brahma for which Murugan replied that imprisonment is the punishment for his Ignorance. Then Siva asked Murugan to explain the meaning of Pranava Mantra 'Om' for which he had given a detailed explanation in His father's ear. Murugan as the Guru and Siva and his disciple. This holy took place at Swamimalai.
It is believed that Goddess Bhudevi relieved from Goddess Parvati's curse by worshipping Murugan. Goddess Bhudevi transformed as a gooseberry tree and stayed here in the temple premises.
This ancient temple was built in 2 BC and later renovated by the Chola Kinga Parantaka I. This temple was heavily damaged during the Anglo-French war.