There was a danava named Maya. Just as Vishvakarma was the architect of the gods, Maya was the architect of the demons. When the demons were defeated by the gods, Maya started to perfrom very difficult tapasya so that the gods might be defeated. Maya‘s meditation inspired two other demons to also meditate. Their names were Vidyunmali and Taraka. The meditation was so difficult that the world marvelled at the sight of what the demons were doing.
Finally, Brahma was pleased at all this effort and appeared before the demons. ― I am pleased with what you have done,‖ said Brahma. ―What boon do you want?‖ ―We have been defeated by the gods,‖ replied Maya. ―We wish to build a fort that the gods will not be able to destroy. The fort will be named Tripura and we will live in it and become immortal.‖ ―Immortality is a boon that cannot be granted.‖ Said Brahma. ―If you want, set fairly difficult conditions for your deaths.‖ ―Very well then,‖ replied Maya. ―We will be killed only if Shiva himself destroys Tripura with a single arrow. Let that be the appoined method of our deaths.‖ This boon Brahma granted and Maya began the task of constructing the fort.
In fact, he built three (tri) fortresses (pura). One was made of iron, the second of silver and the third of gold. Normally, the fortresses were distinct. But once every thousand years, when the nakshatra Pushya was in the sky, the three cities came together in the sky and were called Tripura. Each of the fortresses was stocked with diverse weapons as protections against raids by the gods. Taraka lived in the fort made of iron, Vidyunmali in the one make o f silver, and Maya himself lived in the one that was made of gold. The other demons got to know that three invincible forts had been built. They came and populated the three cities. But the demons were not evil at all. They observed all sorts of religious rites. In particular, they were devoted to Shiva and prayed to him all the time. They did not want Shiva to be angry witht them. It was, after all, Shiva alone who could be the instrument for their destruction.
But eventually, the demons became intoxicated with their own power and came upon evil ways. They warred upon other living beings and started to oppress the universe. Maya did try to persuade them to mend their ways, but the demons would not listen to Maya‘s good advice. All the living beings in the universe went to Brahma to complain. ―Please save us from this oppression,‖ They said, ―It is because of your boon that the demons have become so powerful. ―I cannot help you,‖ replied Brahma. ―The boon is such that Shiva alone can destroy Tripura. Let us all pray to Shiva.‖ The gods, the sages and the humans started to pray to Shiva. Pleased with these prayers, Shiva promised to destroy Tripura.
A special chariot was built for Shiva to ride in. Brahma himself agreed to be the charioteer. The army of the gods got ready to help Shiva in his war against Tripura. A terrible war raged between the gods and the demons. Nandi is one of Shiva‘s companions. Nandi fought with Vidyunmali and slew the demon after a fierce battle. But Maya knew all sorts of magical tricks. He was particularly well-versed in the use of herbs. Maya gave Vidyunmali a bath in the juice of magical herbs and Vidyunmali immediately revived. This act greatly boosted the demons‘ morale and they began to fight with renewed vigour. Any demons,who were killed, were instantly revived by Maya. But when Shiva himself entered the fray, the demons were put to flight. Even the herbs that resurrected dead demons proved to be of no avail. Nandi killed Tarakasura after a fierce duel.
The demons were disheartened, but Maya reassured them. ―Don‘t forget the boon,‖ he said,
―There are only some special conditions under which Tripura can be destroyed. Otherwise it is indestructible. Pushya nakshatra is in the sky now and soon the three cities will come together as one. The only person who can destroy it then is Shiva. And he must do it with a single arrow. All we have to do is ensure that Shiva cannot shoot the arrow and we are safe.‖ But this was easier said than done. It was no mean task to repel Shiva and his cohorts. Nandi killed Vidyunmali a second time. As soon as the three cities came together, Shiva shot a flaming arrow which completely burnt up Tripura and all the demons who were within. The only one who was saved was Maya. He did not die because he was extremely devoted to Shiva. Ever since that day, Maya has lived under the water.