Ayyappa is known as "Hariharan Puthiran" because he is the son of both Hari(Vishnu) and Haran(Siva). His most common name is Manikandan because soon after his birth his parents (Mohini & Shiva) tied a necklace with a bell (mani) around his neck (kandan).
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.