Praise be to Allah.
The ignorance for which a person may be excused is ignorance of the ruling. Whoever does not do an obligatory action because he does not know that it is obligatory, or he does a forbidden action because he does not know that it is forbidden, is an ignorant person who may be excused for his ignorance.
But if a person knows that something is forbidden and he does it, but he is ignorant of the punishment for that, he has no excuse, because he has knowingly committed a sin and transgressed the bounds.
If a person commits zina – for example – and does not know that zina is haram, he will not be punished and is excused for his ignorance. But if a person knows that zina is haram but he does not know that the one who commits zina deserves the hadd punishment, then he has no excuse and the hadd punishment must be carried out on him, if the conditions for that are met.
Similarly, if a person does not pray and he does not know that prayer is obligatory, he is to be excused for his ignorance and is not regarded as a kaafir. But if a person does not pray and he knows that not praying is haram but he does not know that not praying is kufr, then he is not to be excused.
There follows some evidence for the above, as well as some comments of the scholars:
(A)If a person is ignorant of the ruling on the forbidden action and does it, and there is some hadd punishment or expiation required for that, it is not required in his case.
The evidence for that is the words of the Prophet (peace and blessings of Allah be upon him) to a person who confessed that he had committed zina: “Do you know what zina is?” Narrated by Abu Dawood, 4428. This hadith was also reported in al-Saheehayn.
Ibn al-Qayyim – who classed the report of Abu Dawood as saheeh – said: The hadd punishment is not due for one who was ignorant of the fact that it is forbidden, because the Prophet (peace and blessings of Allah be upon him) asked him about the ruling on zina, and he said: I did with her wrongfully haram what a man does with his wife lawfully.
Zaad al-Ma’aad, 5/33.
(B)If he knows that it is haram but is ignorant of the consequences, whether a hadd punishment, required expiation or anything else, then the hadd punishment must be carried out on him because he dared to do something haram, and he must offer the expiation if the sin requires expiation.
The evidence for that is the hadeeh of Maa’iz (may Allah be pleased with him) who confessed that he had committed zina, in which he said: “O people, take me back to the Messenger of Allah (peace and blessings of Allah be upon him), for my people deceived me and killed me.” Narrated by Abu Dawood, 4420; its isnaad was classed as jayyid by al-Albaani (may Allah have mercy on him) in al-Irwa’, 7/354. This Sahaabi (may Allah have mercy on him) knew that it was haram but he was unaware of the punishment.
Ibn al-Qayyim (may Allah have mercy on him) said: This indicates that ignorance of the punishment does not excuse a person from the punishment if he knew that it is haram. Maa’iz did not know that the punishment was execution, but this ignorance did not excuse him from the punishment.
Zaad al-Ma’aad, 5/34.
Similarly, the Sahaabi who had intercourse with his wife during the day in Ramadaan did it deliberately and knew that it was haram. As was pointed out by al-Haafiz ibn Hajar in al-Fath (4/207), this is indicated by the fact that he said “I am doomed” – or according to another report, “I am burned.” The Prophet (peace and blessings of Allah be upon him) ruled that he had to offer expiation, and did not excuse him because he was unaware of it. This was narrated by al-Bukhaari, 1834; Muslim, 1111.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
If someone were to say: Wasn’t the man who came to the Messenger (peace and blessings of Allah be upon him) ignorant?
The answer is: He was ignorant of what was required of him; he was not ignorant of the fact that this was haram. Hence he said, “I am doomed.” If we say that ignorance is an excuse, we are not referring to ignorance of the consequences of this haram action, rather we are referring to ignorance of the ruling on this action and whether it is haram or not. Hence if a person commits zina and is ignorant of the fact that it is haram, and he does not live in a Muslim country, or he is new in Islam, or he lives in a remote area and does not know that zina is haram, then no hadd punishment is to be carried out on him. But if he knows that zina is haram, but he does not know that the hadd punishment for it is stoning, or lashing and banishment, then the hadd punishment should still be carried out on him, because he has transgressed a sacred limit. Ignorance of the consequences of a haram action is no excuse. Ignorance of whether an action is haram or not is an excuse.
Al-Sharh al-Mumti’, 6/417
And Allah knows best.