 According to legend , Varanasi was founded by the god Shiva . The Pandavas , the heroes of the Hindu epic Mahabharata , are also 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 which can provide Moksha ; Ayodhyā , Mathurā , Gayā , Kaśī , Kañchi , Avantikā , and Dwārāvatī are the seven cities known as the givers of liberation . 
