Ruling on the foyer belonging to the mosque
Question

                Do the areas that belong to the mosque, such as the courtyard, foyers and libraries, come under the same rulings as the mosque?.
Praise be to Allah.
    It says in al-Mawsoo’ah al-Fiqhiyyah (5/225): 

    With regard to the addition of the mosque, which is an area 
    that has been added to the mosque to make it larger, if it is encompassed 
    with a stone wall, what may be understood from the comments of the Hanafis, 
    Maalikis and Hanbalis according to the correct view in the madhhab, is that 
    it is not part of the mosque, as opposed to the other view (of the Hanbalis) 
    that it is part of the mosque. Abu Ya’la reconciled the two views by noting 
    that if this addition is surrounded by walls and has a door, then it is part 
    of the mosque. The Shaafa’is were of the view that the addition to the 
    mosque is part of the mosque, and if a person observes i’tikaaf there, his 
    i’tikaaf is valid. 

    Shaykh ‘Abd al-‘Azeez Aal al-Shaykh said: 
Whatever is encompassed 
    by the wall of the mosque and included in the mosque is part of the mosque, 
    and whatever is outside the mosque enclosure is outside the mosque. 

    Majallat al-Buhooth al-Islamiyyah, 
    59/81.