The early Pandya dynasty ruled the southern part of the ancient Tamil region from about the 3rd-century BCE and they remained a major power for nearly 1,000 years They lost their hold on their kingdom to the Cholas for a few centuries, and then returned to power about the 12th-century. They were instrumental in patronizing literature, arts and religious architecture, as well as sharing of ideas and trade with northern kingdoms of ancient India. The Karpaka Vinayakar temple is a testimony and one of the evidence of the early Pandya dynasty contributions to the South Indian heritage.
The temple in its contemporary form has many layers of additions and restorations completed over nearly 1,400 years. The earliest layer that can be dated with certainty is the 7th-century rock-cut cave temple This rock-cut cave is attributed to Narasimhavarma, c. 650 CE. Several rock-cut Hindu gods and goddesses are displayed in this earliest layer. The cave also includes inscriptions and unusual iconography. There are several stone sculptures in the cave, on different faces of the natural rock:

7th-century rock-cut Ganesha
The primary sanctum is dedicated to Ganesha, referred to as the Vinayagar sannidhi (sanctum sanctorum). On the southern face of the rock is a 6 feet rock-cut bas-relief of Karpaga Vinayagar. This Ganesha faces the north direction. As this is a cave excavated in a large natural rocky hillock, there is no provision for the pradakshina, that is circumambulatory passage. The iconography of Ganesha is unusual in several ways.
First, he has only two hands. Second, he holds sweets in his right hand and his trunk is curved at the right side, unlike later statues which typically show him with four hands, trunk turned left and holding sweets in one of his left hands. At the Karpaka Vinayakar relief of Ganesha, his left tusk is broken suggesting that some of the iconographic features of Ganesha were well established by the time this image was carved. Locals call this relief as Valampuri Vinayagar. There is a 7th-century inscription near him that refers to the relief as "Desi vinayagar".
A Shiva sanctum on the west face of cave wall, inside a gajaprashta (elephant-back form of excavation), with the sanctum opening to the east. It has a 7th-century Shiva linga at its center. A notable inscription in this sanctum states "Ikkatturu Kotturu Ainiijan", likely the name(s) of the patron(s) responsible for its excavation. The notability is in the paleographic nature of the inscription. The script is more archaic than the earliest Vatteluttu, with some Tamil Brahmi influence, yet it is clearly not Tamil Brahmi and is later than the 3rd-century CE Tamil Brahmi in its features. This, states the epigraphist and historian R. Nagaswamy, suggests that the inscription inside the rock-cut cave excavation and Hindu iconography here was likely created between the 3rd and 7th-century.
Between the rock-cut Ganesha and the rock-cut Shiva shrine is another unusual bas-relief of a standing royal human form with two attendants. This has been variously interpreted as Ardhanarishwara (half Shiva, half Parvati) or Harihara (half Shiva, half Vishnu) or a king between two officials.[1][2] The difficulty and complexity with these interpretations is its simplicity, lack of classic emblems (icons), and the presence of certain icons. The central standing figure has two hands, in the samabhanga posture with left hand on the hip in katyavalambita posture, all defined in early silpa sastra texts of Hinduism. The right hand is in the boon giving varada gesture per ancient Sanskrit texts. The head of this 7th-century bas-relief is decorated with long elongated jatamakuta (jeweled oblong crown).
The left half of the central figure is clearly different than the right half, though fused. One interpretation is that this may be a Pallava king where this sort of headdress is seen. However, this hypothesis fails because the Pallava dynasty was non-existent at this time in southern Tamil Nadu and were not the sponsor of this cave excavation. Further, there is no reason or example where a king was depicted in Tamil Nadu with two different halves or in boon giving posture. The second hypothesis is that this is an early bas-relief of Ardhanarishwara. This hypothesis is favored by the fact that the left side is more conspicuously feminine and with jewelry (more pronounced breast, dress). A third hypothesis states that this is a different form of Harihara. Nagaswamy favors the Harihara hypothesis primarily because of the crown and how it is carved in the typical kirita-form of crown for the Vishnu side.
The right side of the crown is consistent with Shiva's crown, while the left side with Vishnu, states Nagaswamy. In the South Indian tradition, Parvati is emblematically identified as Vishnu's sister and with some of Vishnu's emblems. The two attendants may be Candesha and Garuda, according to Nagaswamy. Given the lack of emblems in this bas-relief of those typically associated with Shiva, Vishnu and Parvati, this bas-relief can be either Ardhanarishwara or Harihara, albeit unusual in either case.

Mandapam has extensive frescoes, in distance above is one of the shrines.
Another Harihara-like relief is found on the side wall of the excavated cave. Once again, it is two-armed instead of the typical, later era four-armed Harihara. This is a partial bas-relief, carved up to the waist placed above a square shaped pillar outline. Nagaswamy identifies this as Lingodbhava. Once again this is unusual, as Lingodbhava is typically shown with Brahma and Vishnu on each side, or with Brahma implied with hamsa (swan) and Vishnu implied with varaha (boar).
Later expansions added several mandapams (Maha, Thirumurai, Alankara), another Shiva shrine, a Nataraja, a Chandesar shrine, and a Sivakami Amman shrine. On the southern side of mandapam, parallel and near to the excavated cave is a panel with the Saptamatrikas (also called Saptha Kannimar, seven mothers or seven virgins), The temple also includes shrines or dedicated area for Bhairavar (Shiva form) with his dog, Somaskandhar, Kartikeya with his two wives, Karthiyayini (who arrange marriages), Nagalingam (who gifts offspring), Pasupatheeswarar (who showers all wealth), Navagrahas, and two gopurams (east and north sides). For charitable functions, like large Shaiva tradition temples, the Karpaka Vinayakar has a large temple kitchen called madapalli, and a temple well inside the mandapam to provide water for pilgrims. The temple also has space for devotional singing of hymns and performance arts.





Pillaiyaarpatti Temple Gopuram