The earliest monument, the Siva cave temple is assigned to first half of 7th century AD on epigraphical evidences and its architectural style. The Vishnu cave temple may be ascribed to a date not latter than the first half of the 8th century.
Thirumayam later formed part of the territories of the imperial Chozhas.
In the 12th and 13th centuries, the Hoysala-s ruled this place, first as the allies of the Chozhas and later of the Pandya-s. Two inscriptions here refer to Appanna, a Danda-nayaka of the Hoysala army, who, while returning from his victorious march to Rameswaram, presided over an important tribunal, held at Thirumayam to settle a longstanding dispute between the trustees of the Vishnu and Siva temples.
In the 13th century, Thirumayam passed under Pandya rule, and there are inscriptions dated in the reigns of Mara-varman Sundara Pandya II , Jatavarman Veera Pandya III , Jatavarman Parakrama Pandya , and an unidentified Veera Pandya . The Vijayanagara inscriptions are dated in the reigns of Virupaksha I and Krishnadeva-raya (15th and 16th century AD). In the 16th century, the chiefs of Chooraikkudi administered Thirumayam. In the 16th and 17th centuries, the town was a northern outpost of the territories of the Sethupathi of Ramanathapuram , but was directly administered by the Pallava-rayar-s. About the year 1686, Vijaya Raghunatha , popularly known as Kizhavan Sethupathi , of Ramanathapuram, brother-in-law of Raghunatha Raya Tondaiman made over to the latter the area of Thirumayam. Sethupathi Thanda-thevan confirmed this cession in 1723 in return for military help that he received from the Tondaiman against Bhavani Sankar , a rival claimant to the chief ship of Ramanathapuram.
In 1733, Thirumayam was the only place of refuge left to the Tondaiman when the Thanjavur general Ananda Rao overran the whole of the Pudukkottai country. Here Vijaya Raghunatha Raya Tondaiman lay besieged for about a year until Ananda Rao raised the siege and retired. In 1755, The Raja of Thanjavur submitted to the East India Company a claim for Thirumayam, but did not seriously maintain the claim. There is an unauthenticated tradition that, at the time of the ‘Poligar War’ of 1799, the famous Katta-bomman of Panchalankurichchi and his dumb brother had taken refuge in the jungles of Tondaiman territory near Thirukkalambur . They were captured by the Tondaiman and imprisoned for a time in the Thirumayam fort. He then handed over them to the English. During the second ‘Poligar War’, Thirumayam was a depot for Lieutenant Colonel Agnew’s army.
Thirumayam is a place of historical importance and contains three celebrated monuments. They are the Thirumayam Fort and the famous rock-cut shrines of Siva and Vishnu, hewn out of the same rock. The old fort-entrance is also a noteworthy structure. The Vishnu temple is closer to the diversion road and the Siva temple is to west of this. The Siva temple is in the eastern side of the Vishnu shrine.
Protection Thirumayam Fort, Siva and Vishnu temples are protected and controlled by Archaeological Survey of India (ASI) and are declared as National Monuments. The following links provide more details about ASI's participation.