Shasta (IAST Śāstā) is a Hindu deity of Dravidian origin, usually associated with Shiva and Vishnu. In Hindu mythology, Shasta is considered to be another name of Ayyappan, described as the offspring of Shiva and Mohini. His principal function is to act as a kuladevata of a given clan, as well as act as a guardian of a village's boundaries. In South India, he is identified with the Ayyanar in Tamil Nadu and the Ayyappan in Kerala.
Shasta is a generic term that means "Teacher, Guide, Lord, Ruler" in Sanskrit. In South India, a number of deities are associated with Shasta. The Tamil song Shasta Varavu states that there are eight important incarnations and forms of Shasta. This is also present in the agamic work Dyana Ratnavali. The Ashta-Shasta (eight Shastas) are Aadhi Maha Shasta, Dharma Shasta (Ayyappan), Gnana Shasta, Kalyana Varadha Shasta, Sammohana Shasta, Santhana Prapti Shasta, Veda Shasta and Veera Shasta. Brahma Shasta is another term associated with Kartikeya.
In Tamil Nadu, Aiyanar is used as the regional name of the deity Shasta. The earliest reference to Aiynar-Shasta is from the Arcot district in Tamil Nadu. The stones are dated to the 3rd century C.E. They read "Ayanappa; a shrine to Cattan." This is followed by another inscription in Uraiyur near Tiruchirapalli which is dated to the 4th century C.E.
Literary references to Aiyanar-Cattan are found in Silappatikaram, a Tamil work dated to the 4th to 5th centuries C.E. The Tamil Sangam classics Purananuru, Akananuru etc. refer to Ayyanar and "Cattan" in many poems. There are several numerous references to Shasta in Sangam works. Some Tamil inscriptions of the Sangam period and a few of the later Pallava and Chola period coming in from various parts of the kingdoms refer to him as Sevugan and Mahasasta. The hymns of some Alvars like Tirumangai Alvar and Nammalvar in temples like Tirumogur near Madurai refer to Shasta. A Sanskrit work dated prior to the 7th century known as the Brahmanda Purana mentions Shasta as Harihara suta, or the son of Shiva and Narayana (Vishnu), the oppressor of the asuras. There are references in the Puranas that narrate as to how Shasta during his tenure on earth long ago conducted discourses on Vedas and Vedantas to a galaxy of gods and sages.
Later on, the Saivite revivalist Appar sang about Shasta as the progeny of Shiva and Tirumal (Vishnu) in one of his Tevarams in the 7th century. The saint Sambandar, in one of his songs, praises Ayyanar as a celibate god, invincible and terrible in warfare, taking his abode alongside the bhootaganas of Shiva. The place sanctity and history document, or sthala purana of Tiruvanaikkaval, a Shaivite temple near Tiruchi, which was first documented by the sage Kashyapa, informs us that Shasta once served Shiva at that site and after being blessed with a vision was instructed by God to take his abode in the outer sanctorum. It says that Shasta continues to worship him during the day of tiruvadirai. Adi Sankara also has referred to Ayyanar in sivanandalahari in one verse . Some ancient hagiographies have accounted that Sankara was a deivamsam (divine soul portion) of Shasta (sevugan), the same way that Sambandar was a divine portion of Skanda and Sundarar a divine portion of Alagasundarar. He is also known to have composed verses praising the deity but the same are not available to us as of today. From the Chola period (9th century C.E) onwards the popularity of Aiyanar-Shasta became even more pronounced as is attested by epigraphy and imagery.
The Shasta religious tradition is particularly well developed in the state of Kerala. The earliest inscription to Shasta was made in 855 C.E. by an Ay King at the Padmanabhapuram Sivan temple. Independent temples to Shasta are known from the 11th century C.E. Prior to that, Shasta veneration took place in the temples of Shiva and Vishnu, the premier gods of the Hindu pantheon. Since late medieval times, the warrior deity Ayyappa's following has become very popular in the 20th century.