The Shaykh (rahimahullaah) addresses this matter in the course of the discussion of zakah and the ruling on the one who withholds it out of rejection (juhood) of it.
Ignorance (al-jahl) is excused by the Book, the Sunnah and the Ijmaa' of the Muslims in generality (meaning, not in every situation, but in the generality of situations). Evidences from the Qur'an include, "And We never punish until We have sent a Messenger (to give warning)" (17:15), "And We sent not a Messenger except with the language of his people, in order that he might make (the Message) clear for them" (14:4), "And never will your Lord destroy the towns (populations) until He sends to their mother town a Messenger reciting to them Our Verses. And never would We destroy the towns unless the people thereof are oppressors" (28:59), "And if We had destroyed them with a torment before this, they would surely have said: 'Our Lord! If only You had sent us a Messenger, we should certainly have followed Your signs before we were humiliated and disgraced'." (20:134). And in the Sunnah, the saying of the Messenger (alayhis salaatu was-salaam), "Indeed Allaah has pardoned for my Ummah that which occurs due to error, forgetfulness and compulsion." And the evidences indicating that ignorance is an excuse are very many. However is the claim of ignorance accepted from everyone?
The answer is no. For the one who lived amongst the Muslims and denied the prayer, or the zakah, or fasting, or the hajj and said, "I do not know" his saying is not accepted, because this is known to be from the religion by necessity, since both the scholar and the ignorant know this. However, if he was new to Islam, or was raised in the desert far away from the cities and towns, then his claim of ignorance is accepted and he does not disbelieve. But we teach him and if he persisted after the clarification then we judge him with disbelief. This is one of the great matters (requiring) verification and conceptualization. For amongst the people are those who (declare) unrestrictedly, "There is no excuse of ignorance in the foundations of the religion, such as Tawhid, and if we found a Muslim in some of the towns or some of the desert regions worshipping a grave or a wali, and he says he is a Muslim and that he found his forefathers upon this and did not know it was Shirk, he is not to be excused."
That which is correct is that he does not disbelieve, because the first thing that the Messengers came with is Tawhid, and alongside that, the Exalted said, "And we do not punish until after we have sent a Messenger" (17:15). Hence, it is necessary for a person to be an oppressor (i.e. wilfully rejecting truth), otherwise he does not deserve punishment. Further, dividing the religion into foundations (usool) and branches (furoo') was rejected by Shaykh al-Islaam (Ibn Taymiyyah), and this classification did not occur until after the blessed generations, right at the end of the third century. Shaykh al-Islaam said, "How can we say that the prayer is from the brances?!" Because those who divide the religion into foundations and branches make the prayer to be from the branches - yet it is the second pillar from the pillars of Islaam, and likewise, zakah, fasting and hajj. So how can it be said that it is from the branches.
However, in some situations a person is not excused due to ignorance, and this is when it is within his ability to learn, yet he did not do so, despite the doubt (shubhah) being with him. Like a man, when it is said to him, "This is haraam" yet he believes it to be halaal, so here, at the very least, he should have a doubt, and so here, it is binding upon him to learn so that he can arrive at certainty. This person we will not excuse him for his ignorance because he was neglectful in education, and neglect invalidates the excuse. However, the one who is ignorant and he does not have a doubt and believes that that which he is upon is the truth, or he says that this (what he is upon) is the truth, then there is no doubt that this person does not intend opposition, and does not intend disobedience and disbelief. So it is not possible that we make takfir of him until even if he was ignorant of a foundation from the foundations of the religion. For faith in zakah and its obligation is a foundation from the foundations of the religion, yet alongside that, the ignorant one is not declared a disbeliever.
Built upon this, the condition of many of the Muslims in some of the Islamic lands will become clear, those who seek rescue from the dead, and they do not know this is haraam. Rather, they may have been deceived that this is from what brings one closer to Allaah and that this (person) is a wali of Allaah and what resembles the likes of this. Yet these (people) embrace Islam, zealous over it, believing that what they are doing is from Islam and no one has come to them who has explained to them. So these are excused, they are not to be treated as the stubborn opposer (al-mu'aanid), the one to whom the scholars say, "This is shirk" and he says, "But this is what I found my forefathers upon." The ruling upon this one is the ruling upon those about whom Allaah the Exalted said, "Indeed we found our forefathers upon this way and we shall indeed guide ourselves by their tracks" (43:22).
If it is said: How can these people be excused and yet the Ahl al-Fatrah [literally, "people of the interval" those living after the remnants of the teachings of previous prophethood had disappeared] were not excused, for the Messenger (sallallaahu alayhi wasallam) said, "My father and your father are in the Fire", then it is said: It is not for us to go beyond the texts (regarding the Ahl al-Fatrah), for if the Messenger (sallallaahu alayhi wasallam) had not said that his father is in the fire, the requirement of the Shariah principle would be that he would not be punished and that his affair would be with Allaah, just like all the other people of the fatrah (interval). The most correct saying is that the people of the fatrah will be tested on the Day of Judgement with whatever Allaah wills. As for these people, they believe that they are upon Islaaam, and no one has come to them to teach them. In fact, there may be amongst them one from the scholars of misguidance who says (to them) what they are upon is the truth.