Initially the temple was constructed in the 7th century CE by the Pallavas where the current Santhome Church is located. Post its demolition by the Portuguese in 1566 A.D. the Vijayanagara kings reconstructed the temple in the Dravidian style of architecture.Legends state that the place got its name from the fact that Goddess Uma worshipped Lord Shiva in the form of a peacock which is known as Mayil in Tamil. Goddess Uma was being taught the meaning of five lettered Mantra Na Ma Shi Va Ya and the glory of the sacred ash by Lord Shiva, during which she got distracted with the appearance of a peacock.She was then cursed to become a peacock by him. As such to get relieved from the curse she then came to this place and offered her prayers to him. After she regained her original form she was named as Karpagavalli by Lord Shiva. It is at this holy place that Goddess Parvati gave Lord Muruga the spear or Sakthi Vel to kill a demon.It is also believed that Lord Brahma did penance here to get back his creation power from Lord Shiva. A greek researcher, Thalami visited the place around 2000 years ago and named the place as Malliarpa which means the habitat of the peacocks.