Fiqh-us-Sunnah Volume 003, Zakaat and Fasting, Fiqh 3.149B.

Section : I'tikaf, the principles of i'tikaf.

I'tikaf will be fulfilled if a person stays in the mosque with the intention of becoming closer to Allah. If the person is not in the mosque or did not do it with the intention to please Allah, it is not i'tikaf. The fact that the intention is obligatory is proven by Allah words: "They are ordained nothing else than to serve Allah, keeping religion pure for Him." The Prophet said: "Every action is according to the intention [behind it] and for everyone is what he intended."

Certainly, i'tikaf must be done in the mosque, as Allah says: "And do not touch and be at your devotions in the mosque [alBaqarah 178]." This 'ayah proves that if it were proper for i'tikaf to be performed elsewhere, why would Allah exclusively disallow coming to one's wife during i'tikaf. The answer is that since such an act would nullify i'tikaf (no matter where it is performed), it is clear that i'tikaf itself must be in the mosque.

Related Hadith(s)