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 not been born from a Woman's womb. 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 (ambrosia or amrit) 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 slightly more detailed version of the union of Shiva with Vishnu. One version tells that the asura Bhasmasura had so pleased lord Shiva with his austerities that Shiva gave him a boon of anything he wished. So Bhasmasura asked for the ability to burn to ashes anything which he placed his hand over. No sooner had Shiva granted this, than Bhasmasura ran after the god, threatening to turn him to ashes.
Shiva called to lord Vishnu for help. He hid himself in a peepal tree as Bhasmasura ran here and there searching for the god. Vishnu became aware of the events, and decided that he would take the female form Mohini, "the Enchanting", and try to trump the asura's powers. When Bhasmasura saw Vishnu in this form, he was bewitched by her beauty. He earnestly tried to court her. So Vishnu instructed Bhasmasura to hold his hand over his head, and vow fidelity. With this act, Bhasmasura was reduced to ashes.
Vishnu found Shiva and explained the whole affair to him. Shiva asked if he too could see Vishnu in this female form. When Vishnu appeared thus, Shiva was overcome with passion, and united with "her" (Shiva's seed caught in Mohini's hands, per one version of the story). 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 embodiment of their essential identity. Lord Vishnu gifted the new-born deity with a little bejeweled bell necklace, so this god is called Manikanthan Swamy. He is also called Shastha or Shasthappan by most South 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.
Lord Ayyappan had his human sojourn as the son of the Raja (King) of Pandalam, Kerala. 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 Diamond and "kantan" means 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. They 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 stomachache, 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 her stomachache
Manikandan 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 to 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 thai Pongal on January 14, every year,(celebrated as "Makara Jyothi" 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 Garuda 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 14. Immediately after the jewellery is adorned on the Deity, there is an Aarti ( offering by burning Camphor). The miracle is that just after the Aarti, without loss a second, the Jyothi appears on the east side of the Temple up above the Hills of Kanthamalai which also plays an important role in his life(details are given hereunder).
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.