[This is a Pauraanik myth]
Once in the past, when all the Universe had become a single ocean, Brahmaa, Vishnu and Rudra arose from the water. They were alone there at that time, even wise men did not know it. The earth, which had been the domain of former beings, had been destroyed for a piercing wind had arisen and dried up the seven oceans. A single Sun appeared in the east and then a second one in the south, just like the first one, drying up all the waters with his rays and burning all that moved and was still. Then in the west a third Sun arose and in the north a fourth one; and later on eight more Suns arose, and thus there were 12 Suns. [12 Aaditya]
Rudra, the Fire of the Doomsday, arose from the subterranean Hell and filled all the regions out of the sky. The exalted one, as he is known everywhere, burned all of the underworld above and sideways, without exception, and then he went to his dwelling place which he had built before. Then came clouds, rained flooding everywhere and all the regions of the sky with waters. Afterwards, they plunged into the single ocean. There was no earth, no sky, no space, no Heaven. Everything was like a giant cask filled up to the brim.
Then the three eternal Dev came out of the water. The two - Ka (Brahmaa) and Vishnu - bowed to Sarv (Shiv) who blazed with strong energy and said - "You are the Lord of everything, perform creation as you wish." "I will." He said. Then he plunged into the waters and remained immersed for 1,000 celestial years. Then they said to one another - "What will we do without him? How will creation take place?" Hari said to the creator - "Do as I tell you, O Grandfather, let no more time go waste, but make an effort to create progeny, for you are capable of creating various creatures. I will give you my own Shakti (power), so that you will be the creator." So he thought about creating and he creating everything conducive to happiness - Devtaa, Daitya, Gandharv, Yaksh, serpents, men.
When his creation was complete, Shambhoo came out of the water, desirous of creating and thinking about it in his mind. But when he saw the whole sretching above and below with the gods etc, the great Devtaa's heart filled with anger and he thought, "What shall I do now? Brahmaa must have created everything, I will therefore destroy, cutting off my own seed." As he had said this, a flame came out of his mouth and it burned everything.
When Brahmaa saw this, that everything was on fire, he bowed to him and praised him. Shankar got pleased by the praise and told him, "I am Shankar, I will always accomplish everything that is to be done for anyone who seeks refuge with me. Now tell me what should I do with that excess energy which I gathered to destroy you creation. Tell me your desire." Hearing this Brahmaa Jee thought for a while carefully for the welfare of the world, and said - "O Lord. If you are pleased with me, let your energy enter the Sun, since you are the Lord over the Sun, for you are the creator, protector and destroyer. Let us live together with all the immortals in the energy of the Sun, and we will receive the sacred image of the three times (past, present and future) that was given by mankind. Then, at the end of the eon, you take the form of the Sun and burn this Universe at that time."
Shankar agreed to this and laughed, for he was secretly amused, and he said to Brahmaa, "There is no good use for this Ling except for the creation of progeny." And as he said this, he broke it off and threw it upon the surface of the earth. The Ling broke through the earth and went to the very sky. Vishnu sought the end of it below, and Brahmaa flew upwards, but both could not find the end of it for all their vital effort. Then a voice arose out of the sky as the two of them sat, "If the Ling of the god with braided hair is worshiped, it will certainly grant all desires that are longed for in the heart." When Brahmaa and Vishnu heard this, they and all the Divinities worshiped the Ling with their heart set on Rudra.