Is the rooftop or yard on the roof of a mosque considered as a part of the mosque?
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions and all those who follow his footsteps until the Last Day.
We would like to first state that a mosque or masjid (مَسْجِد) in Arabic originated from the verb sujud (prostration) and the word masjid can be read as both masjid or masjad. But the well-known pronunciation is masjid.
Masjid (مَسْجِد) in Arabic means a place of prostration. According to syara’ it can be defined into two: The surface of the earth, this is based on the statement of the Prophet PBUH:
وَجُعِلَتْ لِيَ الأَرْضُ مَسْجِدًا وَطَهُورًا
“The earth has been made for me a place of prostration,” 
While the ‘urf (common in a certain community), the masjid is a place forever designated for prayer. 
AL-Zajjaj said: “Every place of which worship is performed is called masjid as stated in the above hadith.” 
When we look back at the history of the existence and position of land surrounding mosques in previous times according to the definition of the terminology of a masjid, among them is that masjid is just a plot of land where they put signs or borders around it by placing pillars for its border.
If the sign of the border is just the pillars that are made into a masjid or called a masjid by people or wakaf giver – if it is a wakaf mosque- then anything outside the border isn’t considered as a mosque and don’t follow the rulings applicable for a mosque such as iktikaf.
Hence, if a person said: “I make this place as masjid,” then that place will become masjid, which is as large as the space meant as the masjid, while the area outside of it isn’t considered as masjid. In this matter, Imam al-Zarkasyi said: “If a person said: “I want to make a plot of land as a mosque, then according to Al-Wajiz, it become a mosque even if he didn’t state wakaf in his statement.” 
As mentioned above by Imam al-Zarkasyi, if the whole land is gazette or intentioned to be made into a mosque, then the whole land intentioned become a mosque, even when the mosque hasn’t yet been built. However, if only the building is gazette as a mosque, then only such is considered as a mosque and the rest become the mosque’s reserve (reserved land for the mosque and the needs of the mosque).
A mosque is a specially designated place for the five congregational prayers to be continuously performed in it. A mosque can also be defined as a place of prayer at home. This is in accordance with a hadith from Aisyah R.Anha, where she said:
أَمَرَ رَسُولُ اللَّهِ صلى الله عليه وسلم بِبِنَاءِ الْمَسَاجِدِ فِي الدُّورِ, وَأَنْ تُنَظَّفَ, وَتُطَيَّبَ
“Allah’s Messenger (ﷺ) ordered that the mosques be built in residential districts and that it be cleaned and perfumed.” 
The above question is a khilaf among scholars. The first opinion states the rooftop follows the rulings of the mosque. This is the opinion of madhhab Hanafi, Syafie and Hanbali. Imma al-Kasani said: The rooftop of a mosque follows the ruling of the mosque which follows its original ruling. 
Whereas Imam al-Nawawi said, the walls of a mosque regardless of whether it is the outer or inner wall follow the rulings of the mosque itself, where it should be protected and honoured, hence, the same applies for the rooftop of a mosque. 
While the second opinion said, the rooftop isn’t included in the rulings of a mosque. This is the opinion of madhhab Maliki. Ibn Rusyd said it does not inherit the mosque. Most Malikyyah scholars such as al-Baaji stated as such.
We are inclined towards the opinion of madhhab Hanafi, Syafie and Hanbali where it states it is included and considered a part of the mosque. The reason is anything that is related to the mosque, is considered a part of the mosque such as its walls, pillars and rooftop. Hence, it follows the rulings and honor of the mosque. Furthermore, congregational prayer where the congregant is on the rooftop is considered as one performing congregational prayer as long as he can follow the imam with his eyes or he can hear the imam’s voice or follow another person who follows the imam and prays behind him.