Praise be to Allah.
The prohibition on committing evil in Madinah in mentioned in several hadiths, including the following:
It was narrated from Anas (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Madinah… Is a sanctuary from such and such, to such and such. Whoever commits evil (man ahdatha hadathan) in it, upon him will be the curse of Allah, the angels and all the people.” Narrated by al-Bukhaari (1867) and Muslim (1366)
It was also proven in the hadith of ‘Ali (may Allah be pleased with him); narrated by al-Bukhaari (1870) and Muslim (1370).
And in the hadith of Abu Hurayrah (may Allah be pleased with him); narrated by Muslim (1371).
These hadiths, as mentioned above, use the wording “man ahdatha (commits evil)”, not “man adhnaba (whoever sins).”
There are a number of scholarly views concerning the meanings of the phrase “man ahdatha hadathan”:
1. The first view is that it means: whoever commits a sin.
Al-Qaadi ‘Iyaad (may Allah have mercy on him) said:
The words, “Whoever commits evil (man ahdatha hadathan), or gives refuge to an evildoer” mean: whoever commits a sin or gives refuge to someone who commits a sin, and protects him and lets him join him. This is similar to the verse in which Allah, may He be exalted, says concerning Makkah (interpretation of the meaning): “And whoever inclines to evil actions therein or to do wrong (i.e. practise polytheism and leave Islamic Monotheism), him We shall cause to taste a painful torment” [al-Hajj 22:25].
2. The second view is that it does not refer to sin in general terms; rather it refers to a specific sin. This is what may be indicated by the wording in the religious text and by what the people to whom the text was first addressed would have understood from the words “ahdatha hadathan”, which may refer to one of two things:
The first thing is wrongdoing, crimes and stirring up of troubles and turmoil.
Ibn Hajar (may Allah have mercy on him) said:
What is meant by hadath (translated in this instance as evil) and muhdith (translated in this instance as evildoer) is wrongdoing and wrongdoer, as was suggested by some scholars, or it may mean something broader than that.
End quote from Fath al-Baari (4/84)
What may be quoted to support this view is the hadith of ‘Aa’ishah (may Allah be pleased with her), who said: None of their women – i.e., Banu Qurayzah – was executed except one woman, who was with me, talking and laughing so hard that she rolled on her back and her belly, whilst the Messenger of Allah (blessings and peace of Allah be upon him) was killing their men with swords. Suddenly a man called out her name: Where is So-and-so? She said: Here I am. I said: What did you do? She said: Some evil that I committed (hadathun ahdathtuhu). Then she was taken away and executed.
Narrated by Abu Dawood (2671); classed as hasan by al-Albaani in Saheeh Sunan Abi Dawood (2671).
It was said that the evil in question was that she had killed a man among the Sahaabah by throwing a millstone on him.
The second thing to which it may refer is introducing innovations in religion, as in the hadith of ‘Aa’ishah (may Allah be pleased with her) who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever introduces (ahdatha) something into this matter of ours that is not part of it, it will be rejected.” Narrated by al-Bukhaari (2697) and Muslim (1718).
And it says in the well-known hadith: “Beware of newly-invented matters (muhdathaat al-umoor), for every newly-invented matter is an innovation…” Narrated by Abu Dawood (4607); classed as saheeh by al-Albaani in Saheeh Sunan Abi Dawood (4607)
According to this view, ihdaath does not include all sins; rather it refers to committing something bad that is contrary to what is prescribed in religion, that could harm the Muslim community, whether in their religious or worldly affairs.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
He said: “Madinah is a sanctuary, between ‘Iyr and Thawr; whoever commits evil in it (man ahdatha fiha hadathan) or gives refuge to an evildoer, upon him will be the curse of Allah, the angels and all the people.”
What is meant by ihdaath is more specific than just committing a wrong action; rather what is meant is one who introduces in it an innovation that is contrary to what is taught and prescribed. Crimes may be called ahdaath (lit. events or incidents), and what they mean by ihdaath is introducing something that was not there before.
End quote from Majmoo‘ al-Fataawa (6/328-329)
The view that it includes crimes and innovations, but does not include sins in the general sense of the word, is what Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) thought most likely to be correct when he said:
“Whoever commits evil in it (man ahdatha fiha hadathan) – i.e., Madinah – or gives refuge to an evildoer” – here what is meant is two things:
The first is innovation. So whoever introduces an innovation in it has committed evil (ahdatha) in it, because the Prophet (blessings and peace of Allah be upon him) said: “Every newly-introduced matter (muhdathah) is an innovation, and every innovation is a going astray.” So whoever commits evil (ahdatha hadathan) in it – i.e., introduces into the religion of Allah something that Allah did not prescribe – in Madinah, upon him will be the curse of Allah, the angels and all the people, meaning that he deserves to be cursed by every curser – Allah forbid. That is because Madinah is the city of the Sunnah, the city of Prophethood, so how can innovation be introduced in it that is contrary to the Sunnah of the Messenger of Allah (blessings and peace of Allah be upon him)?
The second is fitnah (turmoil), in the sense of stirring up turmoil among the Muslims, whether that leads to bloodshed or something less than that of enmity, hatred and division. Whoever commits this evil, upon him will be the curse of Allah, the angels and all the people.
As for the one who commits sin (ahdatha ma‘siyah) and disobeys Allah in Madinah, this warning does not apply to him; rather it may be said that a bad deed committed in Madinah is more serious than a bad deed committed elsewhere, but the doer does not deserve to be cursed; rather the one who deserves to be cursed is the one who commits evil (ahdatha hadathan) in it by doing one of two things: either by introducing innovation or by stirring up turmoil. This is the one upon whom will be the curse of Allah, the angels and all the people.
End quote from Sharh Riyadh as-Saaliheen (6/213-214)
Committing evil (ihdaath) in Madinah includes crimes, innovation and stirring up turmoil (fitan) that lead to bloodshed, division, enmity and hatred among the Muslims, and it does not refer to all sins in general terms.
And Allah knows best.