Others have said: it applies to both.
Allah, Exalted is He, said to Abraham, peace be upon him,
“Purify My House for those who make tawaf.” (Al-Hajj 26)
This verse requires that the House be kept free from menstrual blood and every other impurity.
Moreover, Abraham—and the prophets after him—used to circumambulate without wudu, just as they used to pray without wudu; their law is our law except where it has been abrogated. As for prayer, we have been commanded to perform it only after ablution, whereas ablution has not been made obligatory for anything else. The earth has been made for us a mosque and a means of purification: wherever a Muslim is overtaken by the time of prayer, there he finds his place of worship and his means of purification. Even if he is in a state of janabah (major ritual impurity), he may make tayammum and pray. Those before us did not have this concession; they were forbidden to pray while junub until they bathed, just as a person in janabah is forbidden to remain in the mosque or to recite the Quran.
A person in minor ritual impurity (a muḥdith) is, however, permitted to stay in the mosque—whether observing iʿtikāf or not—and he may recite the Quran. The only report traced back to the Prophet, may Allah bless him and grant him peace, on this subject mentions just one takbir (saying “Allahu akbar”).