1؎: Sleeping in the mosque is permissible, especially for the traveler. However, for those who have homes, some scholars have considered it disliked (makruh) to make a habit of always sleeping in the mosque. And those who come to the mosque for prayer—if they sleep there, it is permissible; the noble Companions (radi Allahu anhum) have done so.
Explanation & Benefits
Maulana Ataullah Sajid
If a traveler or any other person, due to necessity, sleeps in the mosque, it is permissible, but it should not be made a habit. Similarly, if a person who has come for prayer falls asleep while sitting and waiting for the congregation, there is no harm in it.
Source: Commentary on Sunan Ibn Mājah by Mawlānā ‘Atā’ullāh Sājid, Page: 751
´Ibn Umar narrated:` "We would sleep in the Masjid during the time of Allah's Messenger and we were young men."
Shaykh Dr. Abdur Rahman Freywai
1: The Companions (Sahabah) and the righteous predecessors (Salaf Salihin) used to sleep in the mosque; therefore, there is no doubt regarding its permissibility. The statement of Ibn Abbas radi Allahu anhuma is indeed correct that whoever has a house in the same neighborhood should not spend the night in the mosque. Imam Malik is also among those who hold this view.
Source: Sunan al-Tirmidhi – Majlis ‘Ilmi Dar al-Da‘wah, New Delhi Edition, Page: 321