The exact history of the temple could not determined based on the inscriptions evidence, but the temple is believed to have been built during the Chola period during the 10th-11th centuries.
As per Hindu legend and the Sthalapurana, Shiva was worshipped by Agni, the fire god at this place and the presiding deity came to be known as Agnipureeswarar and the temple tank is called Agni theertham.As per another legend, Bhudevi, the consort of Vishnu wanted to install a Linga and worship Shiva. Banasura, her son, is believed to have dug the Linga at the place, but could not lift it.
The lingam in the place is believed to appear tilted (called Konapiran) on account of it. Shiva was pleased with the devotion of Bhudevi and appeared in his dancing form in front of her. It is also believed to be the place where Shiva turned bricks into gold for the Nayanar Sundarar.
The temple has inscriptions dating from Uttama Chola (970–985 CE) from the 10th century. The inscriptions from the time of Rajaraja I (ARE 47 of 1927-28) indicates tax free gifts of land for conducting festivals and for providing offering to the temple every year by Panchanvan Mahadeviyar, one of the consorts of the ruler.
Another inscription (ARE 68 of 1927-28) dated to the 27th regnal year of the king indicates gift of paddy and money by Angikumara Gramavittan. The inscriptions (ARE 44 of 1927-28) from the period of Rajendra I (1012–1044 CE) indicates exemption of taxes for certain lands belonging to the temple. The records from Rajadhiraja (ARE 49 of 1927-28) indicates offering by Pichan Sirudaikal of Saliamangalam making a gift of offering to the ashtamangalam ceremony, the eight steps of bathing of the deity (mirror, water-pot, flag, fly-wisk, elephant goad, drum, lamp and a pair of fish).
Exclusion of land tax for certain lands of the temple are found from the inscriptions (ARE 79 of 1927-28) from the period of Rajendra Chola II (1054–1063 CE). From the inscriptions it is deducted that the first precinct was probably built during this time. There are also inscriptions from private donors indicating donations of festival images to the temple (ARE 57 & 63 of 1927-28).