Jaya and Vijaya are the two gatekeepers (dwarapalakas) of the abode of Vishnu (Vaikuntha Lok). According to the Bhagavata Purana, the Four Kumaras, Sanaka, Sanandana, Sanatana, and Sanatkumara, who are the manasaputras of Brahma (sons born from the mind or thought power of Brahma), were wandering across the worlds, and one day decide to pay a visit to Narayana - the form of Vishnu that rests on Shesh naga. The Sanat Kumaras approach Jaya and Vijaya and ask to be let in. Now due to the strength of their tapas, the four Kumaras appear to be mere children, though they are of great age. Jaya and Vijaya, the gate keepers of the Vaikuntha stop the Kumaras at the gate mistaking them as children. They also tell the Kumaras that Sri Vishnu is resting and that they cannot see him now. The enraged Kumaras tell Jaya and Vijaya that Vishnu is available for his devotees any time, and cursed both of them that they would have to give up their divinity, be born as mortals on Earth and live like normal human beings.
When Vishnu wakes up, he learns what has happened and is sorry for his two dwarapalakas, who are cursed by the great Sanat Kumaras just for doing their duty. He apologizes to the Sanat Kumaras and promises to his doorkeepers that he will do his best to help them go through the cycle of Life and Death. He cannot lift the curse of the Sanat Kumaras directly, but he puts in front of them two options:
The first option is that they could either be born seven times on Earth as devotees of Vishnu, while the second options is that they could be born three times as His enemy. After serving either of these sentences, they can re-attain their stature at Vaikuntha and be with Him permanently.
Jaya-Vijaya cannot bear the thought of staying away from Vishnu for seven lives, even as his devotees. As a result, they choose to be born three times on Earth even though it would have to be as enemies of Vishnu. Vishnu then takes Avatars and releases them from their lives.
In the first birth as enemy to Vishnu, Jaya and Vijaya were born as Hiranyaksha and Hiraeyakasipu in Satya Yuga. Hiranyaksha was an Asura the son of Diti and Kashyapa. He was slain by the god Vishnu after he (Hiranyaksha) took the Earth to the bottom of what has been described as the "Cosmic Ocean". Vishnu assumed the Avatar of a boar (Varaha Avatar) and dove into the ocean to lift the Earth, in the process slaying Hiranyaksha who was obstructing Him. The battle lasted one thousand years. He had an elder brother named Hiranyakashipu, who after having undertaken penances which made him incredibly powerful and invincible unless several conditions were met, was later slain by the lion-headed Narasimha, another avatar of Vishnu.
In the next Treta yuga, Jaya and Vijaya were born as Ravana and Kumbhakarna, and were killed by Lord Vishnu in His form as Ram.
At the end of the Dwapara Yuga, Jaya and Vijaya were born their third birth as Sisupala and Dantavakra and Vishnu appeared as Krishna and again killed them.
So as they move from one life to another, they move more and more closer to God ... (Asuras being the worst, then rakshasa, then humans and then devas) finally going back to Vaikuntha.
This story actually connects the stories of Bhakt Prahladh, the Ramayan and the Mahabharat in an amazing way.