Whoever dies in Kashi gets Moksha!
Even the Vedas have declared that resorting to Lord Avimukta guarantees Moksha. One who dies at Kashi shall undoubtedly get Moksha whoever be it; be it, sinners, be it animals or even insects and plants will get Moksha, so declares the Shiva Purana.
अत्र तीर्थे विशेषोस्त्यविमुक्ताख्ये परोत्तमे ।।
श्रूयतां तत्त्वया देवि परशक्ते सुचित्तया।।१३।।
सर्वे वर्णा आश्रमाश्च बालयौवनवार्द्धकाः ।।
अस्यां पुर्यां मृताश्चेत्त्स्युर्मुक्ता एव न संशयः ।।१४।।
अशुचिश्च शुचिर्वापि कन्या परिणता तथा ।।
विधवा वाथ वा वंध्या रजोदोषयुतापि वा ।।१५।।
प्रसूता संस्कृता कापि यादृशी तादृशी द्विजाः ।।
अत्र क्षेत्रे मृता चेत्स्यान्मोक्षभाङ् नात्र संशयः ।।१६।।
स्वेदजश्चांडजो वापि द्युद्भिज्जोऽथ जरायुजः ।
मृतो मोक्षमवाप्नोति यथात्र न तथा क्वचित् ।।१७।। (Shiva Purana KotiRudraSamhita chapter 23)
Here in this excellent holy centre Avimukta, there is one special thing to be noted. O goddess, O great Śakti, please listen attentively. People of all castes, of all stages of life, whether children, youths or the aged, if they die in this city, are undoubtedly liberated. O brahmins, whether pure or impure, whether virgin or married, whether widow or barren, whether suffering from menstrual disorders or defects or whether recently delivered of a child, of whatever nature she may be, if she dies at this holy centre she attains salvation. There is no doubt in this. The sweat-born, (lice, bugs etc.) the egg-born (birds), the germinating ones (plants and trees) and the embryo-born (mammals) these living beings do not attain salvation elsewhere as they do at this place.
Neither devotion to lord, nor chanting names of Lord, nor knowledge of the thing that one will get Moksha when he dies at Kashi is needed.
ज्ञानापेक्षा न चात्रैव भत्तयपेक्षा न वै पुनः ।।
कर्मापेक्षा न देव्यत्र दानापेक्षा न चैव हि ।। १८ ।।
संस्कृत्यपेक्षा नैवात्र ध्यानापेक्षा न कर्हिचित् ।।
नामापेक्षार्चनापेक्षा सुजातीनां तथात्र न ।। १९ ।।
मम क्षेत्रे मोक्षदे हि यो वा वसति मानवः ।।
यथा तथा मृतः स्याच्चेन्मोक्षमाप्नोति निश्चितम् ।। 4.23.२० ।।(KotiRudraSamhita chapter 23)
O goddess, there is no dependence on perfect knowledge here, nor that on devotion, nor that on holy rites, nor that on charitable gifts. There is no dependence on culture, nor that on meditation at any time, nor that on repetition of names, nor that on adoration, nor that even on the noble nativity. Whoever may be the man staying in my holy center, whatever may be the manner of his death, if he dies here, he certainly attains salvation.
What happens to the sins of Sinners then?
As clear from above it doesn't matter who dies at Kashi, he will undoubtedly get liberation. But a question naturally arises what happens to the sins committed by the sinners who die at Kashi. Various sins will automatically be destroyed by being in Tirtha Kshetra like Kashi itself, but if still some sins are remaining then one feels like he got many bodies and experiences Yatana which is also known as Bhairavi Yatana. If one commits some sin in Avimukta Kshetra itself then one has to bear that terrible torture for 10000 years also and then will attain Moksha.
अपापश्च मृतो यो वै सद्यो मोक्षं समश्नुते ।।
सपापश्च मृतौ यस्स्यात्कायव्यूहान्समश्नुते ।। ३५ ।।
यातनां सोनुभूयैव पश्चान्मोक्षमवाप्नुयात् ।।
पातकं योऽविमुक्ताख्ये क्षेत्रेऽस्मिन्कुरुते ध्रुवम् ।। ३६ ।।
भैरवीं यातनां प्राप्य वर्षाणामयुते पुनः ।।
ततो मोक्षमवाप्नोति भुक्त्वा पापं च सुन्दरि ।। ।। ३७ ।।
इति ते च समाख्याता पापाचारे च या गतिः ।।
एवं ज्ञात्वा नरस्सम्यक्सेवयेदविमुक्तकम् ।। ३८ ।।(KotiRudraSamhita chapter 23)
If a sinless man dies, he attains salvation immediately. If a sinner dies here he assumes multitudes of births. He attains salvation only after experiencing tortures. He who commits sins in the holy centre of Avimukta, experiences tortures at the hands of Bhairava (Bhairavi Yatana) for ten thousand years and then attains salvation, O beautiful lady. Thus the course of events in regard to one who commits sins has been narrated to you. A man should realize this and worship Avimukta properly.
By "he assumes multitudes of births" we should understand that the sinner will get punishment for his sins mentally and he will feel like he is getting several bodies and getting tortured for the sins he had committed.
By the above description, we can also infer that if a person with some worldly desires also dies in Kashi then he will feel as if those desires were fulfilled by getting some apparent mental births and then attain liberation.
Skandha Purana says that if one commits sin inside Avimukta Kshetra he can get the body of a Rudrapisacha to be tortured and Lord Brahma says that sufferings by that Rudrapisacha are unbearable and even more than that of hell:
स्वयं नियंता विश्वेशस्तत्र काश्यां तनुत्यजाम् ।।
तत्रापि कृतपापानां नियंता कालभैरवः ।। ९३ ।।
तत्र पापं न कर्तव्यं दारुणा रुद्रयातना ।।
अहो रुद्रपिशाचत्वं नरकेभ्योपि दुःसहम् ।। ९४ ।।(Skandha Purana Kashi Khanda chapter 22)
Viśveśa himself is the controller of those who give up their bodies at Kāśī. Kālabhairava is the chastiser of those who commit sins there. No sin should be committed there. Torture from Rudras is highly terrible. Oh, the state of being a Rudrapiśāca is extremely unbearable, more than the sufferings in hell.
Shouldn't Yama Torture the Sinners?
Lord Yama gives torture to sinners by keeping them in Naraka but why is Lord KalaBhairava giving torture in above cases. It is because Kashi doesn't come under authority of Yamaraja as Lord Brahma says in Skandha Purana:
मया सृष्टानि विप्रेंद्र भुवनानि चतुर्दश ।।
अस्याः पुर्या विनिर्माता स्वयं विश्वेश्वरः प्रभुः ।। ८९ ।।
पुरा यमस्तपस्तप्त्वा बहुकालं सुदुष्करम् ।।
त्रैलोक्याधिकृतिं प्राप्तस्त्यक्त्वा वाराणसीं पुरीम् ।। 4.1.22.९० ।।
चराचरस्य सर्वस्य यानि कर्माणि तानि वै ।।
गोचरे चित्रगुप्तस्य काशीवासिकृतादृते ।। ९१ ।।
प्रवेशो यमदूतानां न कदाचिद्द्विजोत्तम ।।
मध्ये काशीपुरी क्वापि रक्षिणस्तत्र तद्गणाः ।। ९२ ।।
स्वयं नियंता विश्वेशस्तत्र काश्यां तनुत्यजाम् ।। (Skandha Purana Kashi Khanda chapter 22)
O eminent Brāhmaṇa, fourteen worlds have been created by me. But the creator of this city is Lord Viśveśvara himself. Formerly Yama performed very severe penance for a long time. He acquired authority over all the three worlds, excepting the city of Vārāṇasī. All the activities of the entire world consisting of mobile and immobile beings are within the ambit of the knowledge (i.e., record) of Citragupta and not so in the case of the residents of Kāśī. O excellent Brāhmaṇa, the messengers of Yama have no right of entry anywhere within the city of Kāśī. The Gaṇas of Rudra stand guard there.
The difference in getting torture in Naraka and Bhairavi Yatana is also that one in Naraka gets a separate body to experience that torture while in the case of Bhairavi Yatana one just experiences the torture mentally and feels that he is in various bodies. But if one commits sin in Varanasi he can also get body of Rudrapisacha and suffer from that body.
Who dies in Kashi?
पूर्वजन्मकृतं चेद्वै काशीदर्शनमादरात् ।।
तदा काशीं च संप्राप्य लभेन्मृत्युं न चान्यथा ।।४७।। (KotiRudraSamhita chapter 23)
If Kashi had been visited with devotion in the previous birth, the person in the present birth reaches Kashi and dies there and not otherwise.
Even if a person visits Kashi once, the seed of that action will ultimately bring him again to Kashi:
पूर्वं चैव कृता काशी पश्चात्पापं समाचरेत् ।।
तद्बीजेन बलवता नीयते काशिका पुनः ।।4.23.५०।।
तदा सर्वाणि पापानि भस्मसाच्च भवंति हि ।।
तस्मात्काशीं नरस्सेवेत्कर्मनिर्मूलनीं ध्रुवम् ।। ।।५१।।(KotiRudraSamhita chapter 23)
If a man visits Kāśī first and commits sin afterwards, the seed of that action takes him again to Kāśī. Then his sins are reduced to ashes. Hence a man shall resort to Kāśī. That certainly debars Karmans to fructify.