King Divodasa Rules Kashi
The story of the performance of this great ritual is set mythologically in a the larger context of the reign of King Divodasa (Ironically servant of heaven') in Kashi. (Linga Purana beginning 39.43) In this story the earth is once again threatened and in danger of collapse, but Brahma finds a king, Ripunjaya, who was performing tapas and could save the world. Brahma came to him to ask him to take control of the world so that order could once again be restored to the universe. He said that he would accept under one condition. the gods had to return to heaven and the nagas to the serpent world. He then took the name of Divodasa.
This prerequisite meant that all the gods who had dwelt in Kashi were now required to leave. Shiva meanwhile had granted Mt. Mandara a boon to be equal to Varanas$ and agreed to dwell there. The new king took control and everything returned to perfect harmony. Many of the gods did not want to leave and so they decided to trick the king. Agni withdrew his fire, vayu his wind and Indra the rain so that in the new kingdom there would be none of these things and the people would loose confidence. However, by the force of his tapas Divodasa created his own fire, wind and rain.
While on Mt. Mandara Shiva was suffering immensely as he was separated from his beloved, Kashi. As a result, Shiva decides to send a series of tricks to the kingdom in order that Kind Divodasa make some mistake and the rule of Dharma (Dharmaraja) become sullied so that the gods could return. He sent a series of messengers, his ganas, Ganesha, Vishnu, the Yogini's the sun, and Brahma. However, they all fail as the king cannot be swayed in his perfection.
The mission of Brahma was to go to Kashi to ask the king for help in performing the great and difficult ten horse sacrifice. The king agreed and as the patron, her would be required to supply the wealth as well as all the necessary materials. Shiva's logic here was that the performance of this ritual was so difficult, he would have to make a mistake. However, the ritual was performed perfect and the place where it was performed became know as Dashashvamedha and pilgrims who travel here are said to receive the merit of this great ritual just by bathing in the Ganges. realizing the kings greatness and the greatness of the city, Brahma could not leave.
Finally, Vishnu traveled to the city and disguised himself as a Buddhist monk and taught the message of the Buddha. Hearing these words, citizens began to disagree with the king and go astray. The king was dismayed and when Vishnu entered his court, the asked how he could end his own karmic process and finally rest. Vishnu informed him that he need only establish a linga for Shiva and he would be transported in a chariot to Shiva's highest heaven. Vishnu then sent Garuda to inform Shiva of the victory so that he too could return to his beloved.