Vaikuntha, the palace of Vishnu, had a pair of brothers as devoted guards at its gate named Jaya and Vijaya. No one entered without their permission. One day the Four Kumaras, perennial children of Brahma born from his mind, came to visit Vishnu and were denied entry as Vishnu was unavailable. So the Four Kumaras sentenced Jaya and Vijaya to life on Earth for their impertinence.
Vishnu came to see what was causing the commotion and found his guards quarreling with the Four Kumaras. When the situation was explained Vishnu, powerless against a curse of the Four Kumaras, offered Jaya and Vijaya either of two options. They could live on Earth for seven lifetimes as his devotees or for three lifetimes as his enemies. They chose the shorter sentence.
Their third lifetime would be spent in the Dwapara Yuga as Dantavakra and Shishupala and they would be killed by Vishnu in the form of Krishna.
Their second lifetime would be spent in the Treta Yuga as Ravana and Kumbhakarna and they would be killed by Vishnu in the form of Rama.
Their first lifetime would be spent in the Satya Yuga, the Golden Age, as the most powerful of their mortal forms Hiranyaksha and Hiranyakashipu and Vishnu would require two avatars to kill them.
All being agreeable the brothers descended into the loins of the great sage Kashyapa, by some accounts the father of all devas, asuras, nagas, and humans by his many wives, all daughters of Daksha, the son of Brahma created from his right thumb.
Long ago the devas and asuras were at war and due to Indra's refusal of a gift in an attempt to demonstrate his mastery over his ego the devas had been cursed with the loss of their strength and were defeated. The asuras were gracious in victory and offered to form an alliance with the devas. Vishnu saw his opportunity and set in motion a plan to restore the power of the devas.
Together the devas and asuras began a project to churn the ocean of milk and doing so produced various things in series including amrita, the nectar of immortality. Vishnu then disguised himself as a sexy woman, Mohini, to distract the asuras while the devas drank the nectar. Kashyapa's second wife, Diti, mother of the asuras, began plotting revenge against Vishnu for this con. She asked Kashyapa to give her two sons who could defeat Vishnu and he impregnated her with Hiranyaksha and Hiranyakashipu.
Vishnu watched with concern as the brothers led the asuras in creating chaos wherever they went. He finally intervened when Hiranyaksha kidnapped Bhudevi, the Earth herself, and hid her at the bottom of the cosmic ocean. He took the form of Varaha, a boar-headed man six thousand kilometres high, and searched the ocean for Bhudevi. When he had found her he and Hiranyaksha fought mightily until Hiranyaksha was defeated. Jaya thanked Vishnu and Varaha set the Earth on his tusks and raised her to her rightful place.
Hiranyakashipu had forgotten why he was in the world in the first place but fate had not. Now Vishnu was his mortal enemy and he would dedicate all his effort towards killing him. Hiranyakashipu went to live in the woods and meditated for many years. In appreciation of his devotion Brahma offered him any gift he desired. Hiranyakshipu asked for immortality but Brahma was unwilling to provide exactly this. So Hiranyakshipu suggested as a work around that he become such that he could never be killed by any god, demon, serpent, or mortal, by any man or any animal, at night or in the day, on Earth, in water, or in the sky, indoors or outdoors, or with missiles or hand held weapons. Brahma agreed and Hiranyakashipu went to look for Vishnu.
While Hiranyakashipu meditated the asuras were without a leader and Indra seized his opportunity and killed as many as he could. Eventually he was able to invade the asuras' capital and Hiranyakashipu's palace. There he found Hiranyakashipu's pregnant wife Kayadhu and decided to take her hostage.
The sage Narada appeared to defend Kayadhu. He asked Indra to leave her be as she had only been an innocent bystander in the war. So Indra left her with Narada who taught her about Vishnu. Her yet to be born child became a devotee of Vishnu along with her.
Since the day the boy, named Prahlada, was born he worshipped Vishnu constantly. When the newly empowered Hiranyakashipu reconquered his kingdom he fancied himself as the mightiest of all gods and could not bear his son's worship of another. He debated the boy and having failed to persuade him tried and failed repeatedly to have him killed. His guards' swords shattered on contact with Prahlada, elephants refused the order to attack him, and when his aunt Holika, who had a cloak that gave her immunity from fire, tried to burn him her cloak was removed from her by a miracle and covered Prahlada and she herself burnt to ashes while Prahlada survived.
In frustration Hiranyakashipu began to kick a pillar in his palace and asked rhetorically if Prahlada thought Vishnu lived in it since he was supposed to be omnipresent. From the pillar leapt a terrifying beast, Narasimha, an avatar of Vishnu with a lion's head and claws, implacably furious. It was dusk and Narasimha dragged Hiranyakashipu to the door way of his palace, laid him on his lap, and tore him asunder with his claws. Vijaya thanked Vishnu and prepared himself for the next life and Prahlada took his father's place as ruler of his kingdom.