According to legend, Varanasi was founded by the god Shiva. There happened a fight between the two supreme gods, Brahma and Shiva, and the succeeding combat resulted in one of the four heads of Brahma being torn off by Shiva. It was a custom of the time that the victor carried the slain adversary’s head in his hand and let it hang down from his hand as an act of ignominy and a sign of his own bravery. A bridle was also put into the mouth. Shiva thus dishonored Brahma's head, and kept it with him at all times. When he came to the city of Varanasi in this state, the hanging head of Brahma dropped from Shiva's hand and disappeared in the ground. The land of Varanasi is therefore considered an extremely holy religious site.
The Pandavas, the mythic protagonists of the Hindu epic Mahabharata, are said to have visited the city in search of Shiva to atone for their sin of fratricide and Brahmanahatya that they had committed during the climactic Kurukshetra War. It is regarded as one of seven holy cities (Sapta Puri) which can provide Moksha; Ayodhya, Mathura, Bodh Gaya, Kashi, Kanchi, Avanti, and Dvaraka are the seven cities known as the givers of liberation.