Answer:
Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
Sleeping in the mosque, any mosque is permissible according to the majority of scholars. The evidence for this is the fact that the companions of the Prophet (Sallallahu Alaihi wa Sallam) used to sleep in the mosque.
Al-Bukhari and
Muslim reported from
Ibn Umar that he said:
"I was a young man and was single and I used to sleep in the mosque during the era of the Prophet (Sallallahu Alaihi wa Sallam)" . In
Ibn Majah 's narration, he said:
"We used to sleep in the mosque during the era of the Prophet (Sallallahu Alaihi wa Sallam)" . The author of "Sharh Al-Muhadhab" said:
'sleeping in the mosque is permissible according to the scholars Ibn Al Mussayeb , A'ta , Hassan and Al Shafi'e ' .
Ibn Abbas said:
"Do not take it as a bedroom" . It is also reported from him that he said:
"If you sleep (in the mosque) for the prayer, then there is no objection to that" .
Al-Awzai said:
'it is dislikeable to sleep in the mosque' .
Malik said:
'there is no objection to that for the people who are foreign to the place. But I do not see that for the dweller' .
Ahmad and
Is'haq said:
'if he is traveling or the like there is no harm to that. But if the person uses the mosque as a permanent sleeping place then that is inacceptable' .
From the above, we conclude that it is lawful for you to do what you asked about.
Allah knows best.