“There is no i’tikaaf except in the three mosque”
Question

I heard a hadeeth which says that i’tikaaf is only valid in al-Masjid al-Haraam (in Makkah), al-Masjid al-Nabawi (in Madeenah) and al-Masjid al-Aqsa (in Jerusalem). Is this hadeeth saheeh?.
Praise be to Allah.Firstly:
The hadeeth to which the questioner is referring was narrated by al-Bayhaqi (4/315) from Hudhayfah, who said to ‘Abd-Allaah ibn Mas’ood (may Allaah be pleased with him): I saw some people who were observing i’tikaaf between your house and the house of Abu Moosa (i.e., in the mosque) and I know that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “There is no i’tikaaf except in the three mosques: al-Masjid al-Haraam…” ‘Abd-Allaah ibn Mas’ood said: Perhaps you forgot and they remembered, or you made a mistake and they were correct. 
This was classed as saheeh by al-Albaani in Silsilat al-Ahaadeeth al-Saheehah (2876).
Secondly:
With regard to the ruling on this matter, the majority of scholars are of the view that it is not essential for i’tikaaf to be observed in one of the three mosques. They quoted as evidence for that the verse in which Allaah says (interpretation of the meaning):
“And do not have sexual relations with them (your wives) while you are in I‘tikaaf (i.e. confining oneself in a mosque for prayers and invocations leaving the worldly activities) in the mosques”
[al-Baqarah 2:187]
The word masaajid in this verse includes all mosques, except those of which the evidence states that i’tikaaf is not valid therein, such as mosques in which prayers are not held in congregation, if the person who is observing i’tikaaf is one of those on whom prayer in congregation is obligatory. See question no. (  48985 )
Imam al-Bukhaari referred to the general meaning of the verse. He said:
Chapter: I’tikaaf during the last ten days (of Ramadaan) and i’tikaaf in any mosque. Allaah says (interpretation of the meaning): “And do not have sexual relations with them (your wives) while you are in I‘tikaaf (i.e. confining oneself in a mosque for prayers and invocations leaving the worldly activities) in the mosques. These are the limits (set) by Allaah, so approach them not. Thus does Allaah make clear His Ayaat (proofs, evidences, lessons, signs, revelations, verses, laws, legal and illegal things, Allaah’s set limits, orders, etc.) to mankind that they may become Al-Muttaqoon (the pious” [al-Baqarah 2:187]. 
The Muslims continued to observe i’tikaaf in the mosques in their countries, as was mentioned by al-Tahhaawi (may Allaah have mercy on him) in Mushkil al-Athaar, 4/205. 
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked about the ruling on i’tikaaf in the three mosques: al-Masjid al-Haraam (in Makkah), al-Masjid al-Nabawi (in Madeenah) and al-Masjid al-Aqsa (in Jerusalem). 
He replied: 
I’tikaaf in mosques other than the three mosques – al-Masjid al-Haraam (in Makkah), al-Masjid al-Nabawi (in Madeenah) and al-Masjid al-Aqsa (in Jerusalem) – is prescribed at the appropriate time, and is not limited to the three mosques. It may be observed in those mosques or in others. This is the view of the imams of the Muslims and the imams of the madhhabs that are followed, such as Imam Ahmad, Maalik, al-Shaafa’i, Abu Haneefah and others – may Allaah have mercy on them – because of the words of Allaah (interpretation of the meaning): 
“And do not have sexual relations with them (your wives) while you are in I‘tikaaf (i.e. confining oneself in a mosque for prayers and invocations leaving the worldly activities) in the mosques. These are the limits (set) by Allaah, so approach them not. Thus does Allaah make clear His Ayaat (proofs, evidences, lessons, signs, revelations, verses, laws, legal and illegal things, Allaah’s set limits, orders, etc.) to mankind that they may become Al-Muttaqoon (the pious)”
[al-Baqarah 2:187]
And because the word masaajid (mosques) is general in meaning and includes all mosques throughout the world. This sentence appears at the end of the verses on fasting, the ruling of which applies to the whole ummah in all regions. So it is addressed to all those to whom the ruling on fasting is addressed. Hence these rulings end with the words (interpretation of the meaning): 
“These are the limits (set) by Allaah, so approach them not. Thus does Allaah make clear His Ayaat (proofs, evidences, lessons, signs, revelations, verses, laws, legal and illegal things, Allaah’s set limits, orders, etc.) to mankind that they may become Al-Muttaqoon (the pious)”
[al-Baqarah 2:187]
It is extremely unlikely that Allaah would address the ummah with words that only include a very few of them.  
With regard to the hadeeth of Hudhayfah ibn al-Yamaan (may Allaah be pleased with him): “There is no i’tikaaf except in the three mosques,” even if we assume that this hadeeth is free from faults, it is referring to the most perfect of i’tikaaf, i.e., that which is observed in the three mosques, because of their honoured status and superiority over others. This usage occurs frequently, where the negative is a statement that something is incomplete, not a denial of its validity. For example the Prophet (peace and blessings of Allaah be upon him) said: “There is no prayer in the presence of food,” etc. Undoubtedly the basic principle with regard to negative statements is to negate or deny, but if there is evidence to the contrary then that evidence should be followed, as in the hadeeth of Hudhayfah. This is if we assume that it is free of faults. And Allaah knows best. 
Fataawa al-Siyaam (p. 493). 
Shaykh Ibn Baaz (may Allaah have mercy on him) was asked: How sound is the hadeeth “There is no i’tikaaf except in the three mosques”? If the hadeeth is saheeh, does that in fact mean that i’tikaaf can only be observed in the three mosques? 
He replied: 
I’tikaaf is valid in mosques other than the three mosques, but it is essential that the mosque in which i’tikaaf is observed is a mosque in which prayers are held in congregation. If no prayers are held in congregation there, then it is not valid to observe i’tikaaf there. But if a person has vowed to observe i’tikaaf in one of the three mosques then he is obliged to do so in fulfillment of his vow. 
Majmoo’ Fataawa Ibn Baaz, 15/444.