Hadith 646B3

قَالَ مَالِك : وَلَا يَبِيتُ الْمُعْتَكِفُ إِلَّا فِي الْمَسْجِدِ الَّذِي اعْتَكَفَ فِيهِ ، إِلَّا أَنْ يَكُونَ خِبَاؤُهُ فِي رَحَبَةٍ مِنْ رِحَابِ الْمَسْجِدِ
Malik, may Allah have mercy on him, said: The person observing i'tikaf should not stay at night except in the mosque where he is observing i'tikaf; however, if his tent is in the courtyard of the mosque, then staying there is permissible.
Hadith Reference موطا امام مالك رواية يحييٰ / كتاب الاعتكاف / 646B3
Hadith Takhrij «شركة الحروف نمبر: 641، فواد عبدالباقي نمبر: 19 - كِتَابُ الِاعْتِكَافِ-ح: 3»