According to legend, the sacred Suyambulingam discovered by the king of Gods indira at Kadambavanam, was later enshrined by him in Madurai. The fact that the Lord is seen on the vehicle of Indira in this temple is said to be proof for this. Many historical evidences of the temple have been found dating back from early A.D The temple was almost completely
destroyed in the year 1310 following the invasion of the Islamic conqueror Malikkapur. As kings who were followers of Islam were noted for their intolerance towards other religions, the invaders destroyed most of the ancient sculptures of the temple. Thirugnanasambandar the Hindu Saint has mentioned the temple in his songs which go back to early 7th century.
The Lord has been described as Alavai Iraivan in his songs. The temple was restored to its pristine glory in the late 14th century when the Hindu Kings came back to power in Madurai. This can also be termed as a new beginning of a new era in the history of the temple, when it was almost rebuilt. The King Thirumalai Naicker played an important role in the construction of the new form of the temple according to records.