Short answer
Yes. Tawaf on the upper floors, the roof or the outer rings of the mataf is valid, because they are part of Masjid al-Haram and the Kaaba's sanctity extends above it. It takes longer, but the reward of tawaf is the same. Tawaf outside the mosque is not valid.
Tawaf must be inside Masjid al-Haram, around the Kaaba and outside the Hijr. Every floor and the roof of the mosque count as the mosque, so tawaf there is valid even if it is higher than the Kaaba, and even with pillars or walls in between.
The four schools agree on this.
Explanation
The Quran says "let them perform tawaf around the ancient House", and Allah told Ibrahim and Ismail to purify the House for those who do tawaf. Scholars agree tawaf must happen around the Kaaba inside the mosque. In the Hanafi school, as with the qiblah, what counts is the Kaaba's space from the ground to the sky, so being above it does not matter. The Shafi'i and Hanbali schools also accept tawaf on the roof.
- Ground floor (mataf): best, especially near the Kaaba, but not required.
- First floor and roof: valid. One round is much longer, so pace yourself.
- Behind Zamzam's old site or pillars: valid; they are inside the mosque.
- Outside the mosque: streets and courtyards beyond the mosque's walls do not count.
- Wheelchairs: the routes on the upper floors are valid for tawaf (see tawaf in a wheelchair).
- Start and end: line up with the Black Stone corner; markers and lights on the upper floors show where.
When the ground floor is packed, going upstairs is often the wiser and kinder choice, especially for women, the elderly and families. For what to say in tawaf, see what to say during tawaf.
The evidence
Quran, Surah Al-Hajj 22:29
ثُمَّ لْيَقْضُوا۟ تَفَثَهُمْ وَلْيُوفُوا۟ نُذُورَهُمْ وَلْيَطَّوَّفُوا۟ بِٱلْبَيْتِ ٱلْعَتِيقِ ﴿٢٩﴾
Then let them end their untidiness and fulfill their vows and perform Tawaf around the ancient House."
Tawaf is around the House.
Quran, Surah Al-Baqara 2:125
وَإِذْ جَعَلْنَا ٱلْبَيْتَ مَثَابَةًۭ لِّلنَّاسِ وَأَمْنًۭا وَٱتَّخِذُوا۟ مِن مَّقَامِ إِبْرَٰهِۦمَ مُصَلًّۭى ۖ وَعَهِدْنَآ إِلَىٰٓ إِبْرَٰهِۦمَ وَإِسْمَٰعِيلَ أَن طَهِّرَا بَيْتِىَ لِلطَّآئِفِينَ وَٱلْعَٰكِفِينَ وَٱلرُّكَّعِ ٱلسُّجُودِ ﴿١٢٥﴾
And [mention] when We made the House a place of return for the people and [a place of] security. And take, [O believers], from the standing place of Abraham a place of prayer. And We charged Abraham and Ishmael, [saying], "Purify My House for those who perform Tawaf and those who are staying [there] for worship and those who bow and prostrate [in prayer]."
Tawaf belongs to the Sacred Mosque.
Where the ruling is recorded
- al-Hidaya, Kitab al-Hajj, on tawaf. Tawaf is valid anywhere inside the mosque, even behind the pillars.
- Radd al-Muhtar (Ibn Abidin), Kitab al-Hajj, on tawaf. Tawaf on the roof of the mosque is valid.
- al-Majmu' (Nawawi), Kitab al-Hajj, bab al-tawaf. Tawaf on the roof of the mosque is valid in the Shafi'i school.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.