In the name of Allah, the Gracious, the Merciful
In the time of the Prophet (s), there were conflicts between Muslims and non-Muslims who had violently resisted the spread of the new religion. The conflicts are reflected in some verses and traditions, but conflict is not the general rule in Islam. These texts need to be interpreted in historical context and within the wider whole of Islamic teachings.
One such text is the narration that the Prophet (s) intended to expel non-Muslims from the Arabian Peninsula.
Umar ibn al-Khattab reported: The Messenger of Allah, peace and blessings be upon him, said:
لأُخْرِجَنَّ الْيَهُودَ وَالنَّصَارَى مِنْ جَزِيرَةِ الْعَرَبِ حَتَّى لاَ أَدَعَ إِلاَّ مُسْلِمًا
I will certainly expel the Jews and Christians from the peninsula until I leave none but Muslims.
Source: Ṣaḥīḥ Muslim 1767, Grade: Sahih
This text is but a snapshot within the larger narrative of the Prophet’s (s) biography (al-sirah). Other narrations demonstrate that this statement was made after the conclusion of a battle that had been instigated by one of the hostile Jewish tribes.
Ibn Umar reported: When the Messenger of Allah, peace and blessings be upon him, was victorious at the battle of Khaybar, he intended to expel the Jews from there, but they asked him if they could remain on condition that they work the land and they would get half of its fruits. The Prophet said:
نُقِرُّكُمْ بِهَا عَلَى ذَلِكَ مَا شِئْنَا
We will allow you to remain upon that as long as we wish.
Source: Ṣaḥīḥ Muslim 1551, Grade: Sahih
They stayed in the area thereafter until Umar expelled them to Tayma’ and Ariha’. This was done for the protection of the region of Hijaz, which contains the two holiest sites of Islam in the cities of Mecca and Medina.
Al-Nawawi comments on this tradition, saying:
وَفِي هَذَا دَلِيلٌ عَلَى أَنَّ مُرَادَ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ بِإِخْرَاجِ الْيَهُودِ وَالنَّصَارَى مِنْ جَزِيرَةِ الْعَرَبِ إِخْرَاجُهُمْ مِنْ بَعْضِهَا وَهُوَ الْحِجَازُ خَاصَّةً لِأَنَّ تَيْمَاءَ مِنْ جَزِيرَةِ الْعَرَبِ لَكِنَّهَا لَيْسَتْ مِنَ الْحِجَازِ وَاللَّهُ أَعْلَمُ
In this narration is evidence that the Prophet intended to expel the Jews and Christians from only a part of the Arabian Peninsula, the region of Hijaz specifically, because Tayma’ is on the Arabian Peninsula but it is not a part of Hijaz. Allah knows best.
Source: Sharḥ al-Nawawī ‘alá Ṣaḥīḥ Muslim 1551
This region is dedicated to the pilgrimage to Mecca and visitation of the mosque of the Prophet (s), so they are off-limits to non-Muslims who might instigate conflict or disrupt the pilgrimage by proselytizing and preaching an anti-Islam message. However, most scholars allowed non-Muslims to visit Mecca and Medina with permission of the government for legitimate business purposes.
Ibn Hajar writes:
لَكِنَّ الَّذِي يُمْنَعُ الْمُشْرِكُونَ مِنْ سُكْنَاهُ مِنْهَا الْحِجَازُ خَاصَّةً وَهُوَ مَكَّةُ وَالْمَدِينَةُ وَالْيَمَامَةُ مَا وَالَاهَا لَا فِيمَا سِوَى ذَلِكَ مِمَّا يُطْلَقُ عَلَيْهِ اسْمُ جَزِيرَةِ الْعَرَبِ لِاتِّفَاقِ الْجَمِيعِ عَلَى أَنَّ الْيَمَنَ لَا يُمْنَعُونَ مِنْهَا مَعَ أَنَّهَا مِنْ جُمْلَةِ جَزِيرَةِ الْعَرَبِ هَذَا مَذْهَبُ الْجُمْهُورِ وَعَنِ الْحَنَفِيَّةِ يَجُوزُ مُطْلَقًا إِلَّا الْمَسْجِدَ وَعَنْ مَالِكٍ يَجُوزُ دُخُولُهُمُ الْحَرَمَ لِلتِّجَارَةِ وَقَالَ الشَّافِعِيُّ لَا يَدْخُلُونَ الْحَرَمَ أَصْلًا إِلَّا بِإِذْنِ الْإِمَامِ لِمَصْلَحَةِ الْمُسْلِمِينَ خَاصَّةً
Those among idolaters are prohibited to reside in the Hijaz specifically, which is Mecca, Medina, and Yamamah and its surroundings, not what is besides that of whatever is referred to as the ‘Arabian Peninsula.’ It is agreed upon by all that they are not prohibited from Yemen, along with the rest of the Arabian Peninsula. This is the way of the majority. The Hanafis give them unrestricted permission except for the sacred mosque, Malik permits them to enter the sanctuary for trade, and Al-Shafi’i said none of them may enter the sanctuary by default, unless permission is given by the Muslim leader in the specific interests of Muslims.
Source: Fatḥ al-Bārī 2888
As such, even after determining to expel the specific Jewish tribes, the Prophet (s) continued to trade with Jews and non-Muslims up until the end of his life, demonstrating that his decree was limited by the context in which it was given.
Aisha, may Allah be pleased with her, reported:
تُوُفِّيَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَدِرْعُهُ مَرْهُونَةٌ عِنْدَ يَهُودِيٍّ بِثَلَاثِينَ صَاعًا مِنْ شَعِيرٍ
The Prophet, peace and blessings be upon him, passed away while his armor was mortgaged to a Jew for thirty portions of barley.
Source: Ṣaḥīḥ al-Bukhārī 2759, Grade: Muttafaqun Alayhi
This fact is consistent with the general rule as stated in the Quran, that Muslims can and should maintain good relations with peaceful non-Muslims.
لَّا يَنْهَاكُمُ اللَّهُ عَنِ الَّذِينَ لَمْ يُقَاتِلُوكُمْ فِي الدِّينِ وَلَمْ يُخْرِجُوكُم مِّن دِيَارِكُمْ أَن تَبَرُّوهُمْ وَتُقْسِطُوا إِلَيْهِمْ ۚ إِنَّ اللَّهَ يُحِبُّ الْمُقْسِطِينَ
Allah does not forbid you from those who did not fight you in religion and did not expel you from your homes, that you be good and generous to them. Verily, Allah loves the generous.
Surat al-Mumtahanah 60:8
In sum, the Prophet’s (s) order to expel Jews, Christians, and idolaters from the Arabian Peninsula was specific to the Hijaz region and for the objective of securing the regional pilgrimage from hostile forces. Non-Muslims are allowed to visit Mecca and Medina for legitimate reasons and with permission from Muslim leaders, but not for proselytizing and preaching against Islam.
Success comes from Allah, and Allah knows best.