Staying in the Masjid for worship and its Conditions
Question :
Is staying in the Masjid for worship during the month of Ramadhan a compulsory Sunnah? What are its condi- tions in times outside of Ramadhan?
Answer:
Staying in the Masjid for worship during Ramadhan is Sunnah. The Prophet did it during his lifetime and his wives did it after his death. The people of knowledge have mentioned that there is a consensus among the scholars that it is Sunnah. However, staying in the Masjid for worship should be done in the manner that agrees with the purpose for its legislation. This is that the person remains in the Masjid for the obedience of Allâh. He does this by leaving off worldly acts for the sake of performing acts of obedience to Allâh. He stays far away from his worldly affairs and he does various acts of obedience, such as prayer, remembrance of Allâh and other things. The Messenger of Allâh used to stay in the Masjid for worship while seeking the Night of Decree (Laylatul-Qadr). The person who stays in the Masjid for worship avoids worldly deeds. Thus, he does not sell, he does not buy, he does not leave out of the Masjid, he does not follow the funeral procession, and he does not visit the sick person. In reference to what some of the people do of staying in the Masjid and then some visitors come to visit them during the night and at the ends of the day, and along with that they have forbidden conversations, this contra- dicts the purpose of staying in the Masjid.
However, if someone visits the person staying in the Masjid from among his family members and they speak with him, there is no harm in that. It has been reported from the Prophet that Safiyyah visited him while he was staying in the Masjid and she spoke with him. What is important is that the person make his staying in the Masjid for drawing near to Allâh, glory be unto Him, the Most High.
Source:
Ash-Shaykh Ibn 'Uthaimin
Fatawa Islamiyah, Vol. 3 Page 331