The legend of Kashi states that Lord Shiva himself lived here. This is his winter place. He lived as an ascetic in the upper regions of the Himalayas, but when he got married to a princess, compromises had to be made. And being a graceful man, he decided he would move to the plains, as Kashi was the most fabulously built city at the time.
There is a beautiful story.
Once Shiva left Kashi because of some reasons. The gods were afraid that Kashi would lose its reverberence if it was not properly managed, so they called for help of Lord Brahma.
Lord Brahma, the creator of universe, was concerned. After a long search for a solution, he found a sage of royal blood performing hard tapa in the jungle near the city of Banaras. Lord Brahma made his decision.Ripunjay was deep submerged in tapa when he heard a voice inside his head, “Open your eyes, my child.”Ripunjay opened his eye to find the four headed God emerging from his fire. Devoted prince bowed to Lord Brahma.Brahma looked at Ripunjay kindly and said, “O man of high soul! Time has come when you should bear the crown. Take the world under your throne and save the humanity from fall. By my aid, thou shalt reign over the world and reform the dharma.
Ripunjay listened calmly and fathomed the offer made by the Lord. Being Strongly independently minded, Ripunjay made some decisions of his own and then spoke, “My lord, I shall happily do what you command. But on one condition, I wish to rule in peace without intervention, so I could reform the dharma without any disturbance. I wish all Gods and Godly entities to not set feet upon my land and remain in the heaven only.”
“So be it” said Brahma.Therefore, on the command of Brahma, all Gods left to the heaven.
Brahmaji also kept a condition that King should be an excellent administrator and that every person staying in his kingdom or visiting his kingdom should be treated well with proper religious pursuits. King agreed.
Ripunjay was then renamed to King Divodasa. He took the throne and worked vigorously to bring order in the decaying world. With the favours obtained from Lord Brahma, he established a rule so flawless that was never seen before. Under his reign, his subjects prospered and justice flourished.
As time passed, Lord Shiva desired to again come back to his own city. But due to Brahma’s boon to Divodasa, he was unable to set feet in Kashi. Soon Lord shiva came to know that other gods too are unable to stay in his city. Not happy with this kind of attitude of the Divodasa, Lord Shiva decided first to cast some dents into the flawlessness of Divodasa’s rule in order to reduce his powers and to end his reign.
For this he first sent messengers. They came and they just loved the city so much, they didn’t go back. He summoned sixty yoginis on the advice of his wife Goddess Parvati. He commanded the band to go to Kashi and disrupt the perfectness of Divodasa’s rule. He said, “Somehow corrupt the king. Once we find some fault in him, we can send him packing and I’ll come back.” When the yoginis arrived at Kashi, they were overwhelmed after seeing the perfectness. They abandoned the thought of causing any harm to it. Instead, they decided to never leave the city.
When they did not return, Lord Shiva sent Surya– the God of Sun, to Kashi. But once he saw the city, Surya walked on the same path as the band of Yoginis. Surya Deva was so ashamed and scared that he could not fulfill Shiva’s mission because his love for the city was greater than his commitment to the mission, so he turned south and tilted to one side and settled down.
Then Shiva sent Brahma. He persuaded him to undo what he had done. Lord Brahma admitted that even he could not have removed Divodasa from the throne. But he assured Shiva to do something. He took the guise of a Sadhu– a holy man and entered Kashi. Soon he had the king under his influence. And then he recommended Divodasa to arrange an Ashwamedh Yagya with ten horses. An Ashwamedh Yagya is a ritual practised by mighty kings, in which a horse is made to roam freely through all lands. Army of the king follows the horse. The land through which the horse walks through, comes into the supremacy of the yagya performing king. If someone refuses to accept the supremacy of the king, then they have to battle against the army following the horse.
Brahma suggested the mighty king to practice the yagya with ten horses, in order to make it more difficult. In this way Divodasa’s army was divided into ten parts to follow each horse. Ten armies of the king followed the ten horses in ten directions. But yet no enemy could capture any of the ten horses. To Brahma’s dismay, horses came back safely with their armies. Lord Brahma was much ashamed of the failure of his trickery and abandoned the thought of any other attempt.
Brahma himself came and loved it, and he did not go back.
Then Shiva said, “I cannot trust any of these people” and he sent two of his most trusted ganas. Both of them came, but they loved the place so much and thought, “This is the only place Shiva should live, not Mount Mandara.” So they stayed there and became dwarapalakas of this city.
Lord Shiva saw few more attempts going in vain; and his desire to return to his beloved city was ever increasing. At last, he approached Lord Vishnu. Vishnu is the one who often rescues the Gods in such crisis. A strong scheme was laid out by him, again.
In accordance to the plan, Ganesh, son of Shiva arrived at Kashi in the disguise of an astrologer. Having a long term scheme, he established his residence near the city and began serving the citizens as astrologer. Fame of the astrologer spread in the kingdom. Touched by wind of the fame, the queen also sought his service, and was impressed by the astrologer. Once the queen was impressed, astrologer did not need very long time to reach the royal court of the king.
In the royal court, he pretended to study the palm of king attentively. Finally lord Ganesha succeeded to convince the king that having everything in Kashi still king had no mental peace. At the end, he declared that a holy and wise sadhu would come to see the king on the eighteenth day. Council of the wise man would bring wealth of enlightenment.
So Lord Vishnu went to Varanasi and first arrived at the confluence of the Varuna and Ganges Rivers where He bathed. Now there is the Adi Keshava (“original Keshava” or Vishnu) temple at that location to commemorate the incident, which is now an important tirtha or holy place.
Lord Vishnu came in disguise of saint & told the King “Undoubtedly you are the one who established Law of Dharma on earth again & saved it. You are the one who created every element by sheer power of Dharma just to save earth. But just one deed of yours to ask Shiva to leave his beloved city is cursing your mental peace. By no means is your deed right. You need to correct it by making a Shiv Linga & worship him to come his city-Anandavan and Lord Shiva returned to his city. The Lord as Saint said to king that on the 7th day after installation of Shiva linga, a celestial plane will appear and grant moksha to the king by carrying him to Lord Shiva’s abode. The shivalinga installed was named after the king as Divodaseswara Shiva. This deity is still in Varanasi near Vishwa Bhuja Gauri temple at Dasaswamedha Ghat.
Thus Lord Vishnu caused the departure of King Divodasa and gave Varanasi back to Lord Shiva, and Lord Vishnu and Shiva, along with other demigods and goddesses, have manifested themselves here in many ways ever since. You can find all varieties of temples dedicated many personalities. Thus, they say that all the gods reside here. And it is said that all of the holy places of India can be found in certain portions of the town. Mathura is found in one part of the town, Ayodhya in another, as well as Badrinatha, Dwaraka, and so on. In fact, some of the ancient texts say that Varanasi is not of this earth, but is a holy place and part of the spiritual realm. Therefore, dying in this city brings salvation from future material existence. So there is a strong atmosphere of devotion here as many pilgrims come from all over to spend their last days living in this city, bathing in the sacred Ganges, visiting temples, and having darshan of the deities, all for spiritual purification.