According to Hindu mythology, Varanasi was founded by Shiva, one of three principal deities along with Brahma and Vishnu. During a fight between Brahma and Shiva, one of Brahma's five heads was torn off by Shiva. As was the custom, 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. Varanasi is therefore considered an extremely holy site.
The Pandavas, the 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 Brāhmanahatya 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, Haridwar, Kashi, Kanchi, Avanti, and Dvārakā are the seven cities known as the givers of liberation. The princesses Ambika and Ambalika of Kashi were wed to the Hastinapur ruler Vichitravirya, and they later gave birth to Pandu and Dhritarashtra. Bhima, a son of Pandu, married a Kashi princess Valandhara and their union resulted in the birth of Sarvaga, who later ruled Kashi. Dhritarasthra's eldest son Duryodhana also married a Kashi princess Bhanumati, who later bore him a son Lakshman Kumara and a daughter Lakshmanaa.