Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:9:28

O you who have believed, indeed the polytheists are unclean, so let them not approach al-Masjid al-Haram after this, their ˹final˺ year. And if you fear privation, Allah will enrich you from His bounty if He wills. Indeed, Allah is Knowing and Wise.  

O you who believe, the idolaters are indeed unclean, ˹they are˺ filth, on account of their inner vileness, so do not let them come near the Sacred Mosque, that is, let them not enter the Sanctuary, after this year of theirs, year 9 of the Hijra. If you fear impoverishment, poverty, as a result of the cessation of their commerce with you, God will surely enrich you from His bounty, if He will: and He indeed enriched them through conquests and ˹the imposition of˺ the jizya. God is Knowing, Wise.
القرآن:٩:٢٨

يَا أَيُّهَا الَّذِينَ آمَنُوا إِنَّمَا الْمُشْرِكُونَ نَجَسٌ فَلَا يَقْرَبُوا الْمَسْجِدَ الْحَرَامَ بَعْدَ عَامِهِمْ هَٰذَا ۚ وَإِنْ خِفْتُمْ عَيْلَةً فَسَوْفَ يُغْنِيكُمُ اللَّهُ مِنْ فَضْلِهِ إِنْ شَاءَ ۚ إِنَّ اللَّهَ عَلِيمٌ حَكِيمٌ  

{يا أيها الذين آمنوا إنما المشركون نجس} قذر لخبث باطنهم {فلا يقربوا المسجد الحرام} أي لا يدخلوا الحرم {بعد عامهم هذا} عام تسع من الهجرة {وإن خفتم عَيْلةٌ} فقرا بانقطاع تجارتهم عنكم {فسوف يغنيكم الله من فضله إن شاء} وقد أغناهم بالفتوح والجزية {إن الله عليم حكيم}.