Is it permissible to make the intention for i‘tikaaf (spiritual retreat) in the mosque even before actually starting it and to express this by saying, “I intend to observe i‘tikaaf as long as I am staying in the mosque?” I heard the imam say this on some occasion.
All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and messenger.
The questioner may make the intention for i‘tikaaf during his stay in the mosque and, according to the Shaafi‘i scholars and those who agreed with them in this regard, his i‘tikaaf would be valid. According to their view, i‘tikaaf is valid in such a case, no matter how short one stays in the mosque. Some set the minimum period for i‘tikaaf to a period as short as a bit above the time that takes one to stay stable for a short while.
In his book al-Furoo‘, Ibn Muflih said:
It is desirable for whoever goes to the mosque for prayer or whatsoever to make the intention of i‘tikaaf for however long he is going to stay in it, particularly if he is fasting. The same meaning is stated in Al-Ghunyah in agreement with the Shaafi‘i scholars. However, Shaykh Al-Islam Ibn Taymiyyah did not agree with this.
Yet, the intention for i‘tikaaf must be present when entering the mosque. In Al-Minhaaj Sharh Muqaddimat Al-Hadhrami, a book on the Shaafi‘i school of Fiqh, Al-Haytami refers to the conditions of i‘tikaaf saying, “The seventh condition is to make the intention of i‘tikaaf at the very time of entering the mosque, just like in prayer and fasting.”
With this in mind, if a person goes to the mosque for prayer or any other purpose and wants to observe i‘tikaaf during his stay therein, then he must make the intention for this i‘tikaaf when entering the mosque, so that his i‘tikaaf would be accompanied by the intention from the first moment.
Allaah Knows best.
You can search for fatwa through many choices