Out of his powers Vishnu created a man. This man’s head was shaven, his clothes were faded and he carried a wooden water-pot in his hands. He covered his mouth with a piece of cloth and approached Vishnu. "What are my orders?" he asked Vishnu.
"Let me explain to you why you have been created", replied Vishnu. "I will teach you a religion that is completely against the Vedas. You will then get the impression that there is no svarga (heaven) and no naraka (hell) and that both heaven and hell are on earth. You will not believe that rewards and punishments for deeds committed on earth are meted out after death. Go to Tripura and teach the demons this religion, which they are dislodged from the righteous path. Then we will do something about Tripura".
They were trained by Vishnu himself. Therefore, their teachings were convincing and they had many converts. Even the sage Narada got confused and was converted. In fact, it was Narada who carried news of this wonderful new religion to king Vidyunmati. King, he said, there is a wonderful new teacher with a wonderful new religion. I have never heard before. I have got converted.
Shiva installed a divine weapon known as pashupatiastra(the arrow of pashupati- another name given to Lord Shiva ) into his arrow and shot it at Tripura. The arrow burnt up Tripura into ashes in a split second. While the celebrations were going on, the shaven-heads religious teachers arrived. "What are we supposed to do now?" they asked.
Brahma and Vishnu told them to go the desert where there are no humans . The last of the four eras was kaliyuga and in kaliyuga, evil would reign supreme. When kaliyuga arrived, they were to come back and begin their teaching afresh.And once they reached at their peak god will take rebirth and will wipe them from earth and once again the world will be free from all kinds of demons.
Source : Tripurasura