The asura princess Mahishi was burning up with anger at the trick the gods had pulled on her brother, the asura king Mahishasura. As Mahishasura was blessed with invulnerability to all men, the gods had sent goddess Durga, to fight and kill him. Thus, Mahishi began performing a fearsome set of austerities, and pleased the creator god Brahma. He granted her the boon of ruling the universe and being invulnerable except to a being that had the combined strength of both Shiva and Vishnu. Since such a person did not exist, she thought she was safe and began conquering and plundering the world.
The gods implored Shiva and Vishnu to save them from this catastrophe. Vishnu found a possible solution to the problem. When Vishnu had taken on the Kurma Avatar, he also had to manifest himself as Mohini, the enchantress, to save the nectar of immortality from the demons who were not willing to share it with the gods. If he became Mohini again, then the female Mohini and the male Shiva could have the divine child who would combine their powers and beat Mahishi.
Some versions give a sightly more deatiled version of the union of Shiva with Vishnu. One version tells that the asura Basmasura had so pleased lord Shiva with his austerities that Shiva gave him a boon of anything he wished. So Basmasura asked for the ability to burn to ashes anything which he placed his hand over. No sooner had Shiva granted this, than Basmasura ran after the god, threatening to turn him to ashes.
Shiva called to lord Vishnu for help. He hid himself in a certain tree as Basmasura ran here and there searching for the god. Vishnu became aware of the events, and decided that he would take his transvestite form Mohini, "the Enchanting", and try to trump the asura's powers. When Basmasura saw Vishnu in this form, he thought it was a real woman, and was bewitched by "her" beauty. He earnestly tried to court her. So Vishnu instructed Basmasura to hold his hand over his head, and vow fidelity. With this act, Basmasura was reduced to ashes.
Vishnu found Shiva and explained the whole affair to him. Shiva asked if he too could see Vishnu in this transexual form. When Vishnu appeared thus, Shiva was overcome with passion, and united with him. The two gods thus became "HariHara Murthy", that is a composite form of Shiva and Vishnu as one god.
From this union lord Ayyappan was born. He combines in himself the powers of Vishnu and Shiva, and is a visible embodiement of their essential identity. Lord Vishnu gifted the new-born deity with a little bejeweled bell necklace, so this god is called Manikanthan Swamy. The Tamils call him Ayyanar, and he is also called Shastha or Shasthappan by most Soouth Indian communities.
In most Tamil versions of the story, the legend ends with the birth of the god, and with his passage around the region. But in Kerala, the story continues with Ayyappan's adoption by the Pandalam Raja, and the subsequent encounter with Mahisi.
Early Childhood :
Lord Ayyappan had his human sojourn as the son of the Raja (King) of Pandalam. At that time, Raja Rajasekhara ruled the kingdom of Pandalam. During one of his hunting expeditions, the Raja was puzzled to hear the wails of a child on the banks of the River Pampa. He moved in the direction of the voice to find a resplendent infant there. The beautiful baby with radiant face wore a gemstone (precious stone) around his neck, hence the name Manikantan ("Mani", means gemstone and "kantan" means wearer around the neck). Manikantan was born of Hari (Lord Vishnu) and Hara (Lord Shiva), with Hari assuming the form of a female (Mohini). Hence Ayyappan is also named as Hariharasutan (Sutan meaning Son).The king, though pious, charitable, just, and God-fearing, had no children. The king was an ardent devotee of Lord Shiva and his queen was devotee of Lord Vishnu. The had prayed to their respective deities for blessings in the form of a child. He accepted the child as God's gracious response to his fervent prayer for an heir to his throne. Manikantan was given proper education and training and he grew into a boy well versed in academic lore and martial arts of the time like Kalaripayattu. The Cheerappanchira kalari at Muhamma, in Alappuzha District was responsible for his training in the martial arts. Meanwhile the Rani (Queen) gave birth to a son, however the king regarded Manikantan as his elder son and decided to crown him as the Yuvaraja (heir).
Since the minister of the Raja was always against Manikantan becoming the Yuvaraja, he along with his sycophants turned the queen against the king's decision. On the coronation day of Manikantan as Yuvaraja, the queen pretended to be suffering from unbearable stomach ache, and said she was unable to get any relief from the treatment of any doctor (Vaidya). Finally a fake practitioner appeared at the instance of the minister, and prescribed "the milk of a tigress" as the cure of the queen's illness. The king appealed to one and all to get the tigeress-milk, but no-one dared. At last, Manikantan volunteered and went to the forest in search of tigress Milk, despite the king's attempt to stop him. The king was deeply frightened that the deemed Yuvaraja may not come back alive.
Manikantan entered the forest to fulfill his divine duty, to rid the world of demoness Mahishi. Manikantan killed her and released a beautiful woman who had been cursed to become Mahishi. The young woman asked Ayyappan for his hand in marriage, but he declined, being a celibate. However he promised that she would be visited by pilgrims and would be housed next to his temple, and if the number of new pilgrims visiting him stopped, then he would marry her. Hence she is now worshiped as Maalikapurathamma. There is also another version of this story. It is believed that Maalikapurathamma was a young girl in Cheerappanchira family where Ayyappan was trained for Kalari (martial arts).
On the death of Mahishi, Indra - the king of the gods, who was displaced and banished by Mahishi, led several tigers for the disposal of Ayyappan.
Days later Manikantan entered the palace precincts riding a fierce tigress and followed by a pack of her cubs. The schemers were frightened into confessing their plot. They were convinced of his divine origins, and prayed to him to be with them for their own salvation and for the safety of the kingdom. Immediately Manikantan disppeared. The king would not eat anything if Manikantan did not come back. Then Manikantan gave a vision (Darshan) to the king.
Filled with emotions of happiness, grief, fear, wonder and 'Bhakti' (devotion to God) and self-surrender, the king stood praying for the mercy and blessings of Manikantan. He repented he could not fully visualize the truth of the divine powers of the Lord and repeatedly requested Him to forgive him for behaving as if He were his son only. The Lord lovingly embraced the King who prayed to bless him by freeing from ego and the worldly life of birth and rebirth and grant Moksha (salvation). He told the King that he was destined to return. The king implored Lord Manikantan to allow him to build a temple and dedicate it him and the Lord assented.
Manikantan then enlightened the King on the path of attainment of Moksha. The Lord shot an arrow that fell at the top of Sabrimala and told the King that he could construct a temple at Sabarimala, north of the holy river Pampa and install His deity there. Ayyappan also explained how the Sabarimala pilgrimage shall be undertaken, emphasizing the importance of Penance vratham and what the devotees can attain by His 'darshan'.
But before the departure of the Lord, the King secured a promise from the Lord that on His birthday on January 14, every year,(celebrated as "Makara Jyothy" all his personal jewellery (usually kept at the Palace) will be adorned on His image at Sabarimala. Hence on the 12th of January every year, the Jewellery will be taken on foot from the Palace by a special emissary of the kingdom, after the puja with all pomp, devotion and reverence. Immeditely when the Arti is over, Royal Garuda (Eagle) flies over the Palace, (which seems to be quite automatic). The Royal Garuda flies ahead, and appears guide the pilgrims throughout their journey. Since there was no modern means of communication like Telephone or Mobile, to the hundreds of thousands of Devotees desirous of worshipping Lord Manikantan's Jewels enroute to His Abode, this Garud was the sole and absolute signal of advance information even to the Temple authorities at Sabarimala to get ready for the adorning of the Jewels. This journey on the 12th and 13th of January finally reaches Sabarimala on January 14th. Immediately after the jewellery is adorned on the Deity, there is an Aarti ( offering by burning Camphor). The miracle is that just after the Arti, without loss a second, the Jyothy appears on the east side of the Temple up above the Hills.
But then the Lord further consoled the King saying that the devotees who held him and his descendants in 'Bhakti' shall happen to be devoted to Him as well. Manikantan then blessed the King and all others assembled there, and vanished. The King duly constructed the temple at Sabarimala, dedicated to him. The deity for installation was prepared by Parasurama, an incarnation of Lord Vishnu, and was installed by himself.