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:4:90

Except for those who take refuge with a people between yourselves and whom is a treaty or those who come to you, their hearts strained at ˹the prospect of˺ fighting you or fighting their own people. And if Allah had willed, He could have given them power over you, and they would have fought you. So if they remove themselves from you and do not fight you and offer you peace, then Allah has not made for you a cause ˹for fighting˺ against them.  

Except those who attach themselves to, ˹who˺ seek refuge with, a people between whom and you there is a covenant, a pledge of security for them and for whoever attaches himself to them, in the manner of the Prophet’s (s) covenant with Hilāl b. ‘Uwaymir al-Aslamī; or, those who, come to you with their breasts constricted, dejected, about the prospect of fighting you, ˹being˺ on the side of their people, or fighting their people, siding with you, in other words, ˹those who come to you˺ refraining from fighting either you or them, then do not interfere with them, neither taking them as captives nor slaying them: this statement and what follows was abrogated by the ‘sword’ verse. Had God willed, to give them sway over you, He would have given them sway over you, by strengthening their hearts, so that assuredly they would have fought you: but God did not will it and so He cast terror into their hearts. And so if they stay away from you and do not fight you, and offer you peace, reconciliation, that is, ˹if˺ they submit, then God does not allow you any way against them, ˹He does not allow you˺ a means to take them captive or to slay them.
القرآن:٤:٩٠

إِلَّا الَّذِينَ يَصِلُونَ إِلَىٰ قَوْمٍ بَيْنَكُمْ وَبَيْنَهُمْ مِيثَاقٌ أَوْ جَاءُوكُمْ حَصِرَتْ صُدُورُهُمْ أَنْ يُقَاتِلُوكُمْ أَوْ يُقَاتِلُوا قَوْمَهُمْ ۚ وَلَوْ شَاءَ اللَّهُ لَسَلَّطَهُمْ عَلَيْكُمْ فَلَقَاتَلُوكُمْ ۚ فَإِنِ اعْتَزَلُوكُمْ فَلَمْ يُقَاتِلُوكُمْ وَأَلْقَوْا إِلَيْكُمُ السَّلَمَ فَمَا جَعَلَ اللَّهُ لَكُمْ عَلَيْهِمْ سَبِيلًا  

{إلا الذين يصلون} يلجئون {إلى قوم بينكم وبينهم ميثاق} عهد بالأمان لهم ولمن وصل إليهم كما عاهد النبي ﷺ هلال بن عويمر الأسلمي {أو} الذين {جاَءُوكم} وقد {حَصِرَتْ} ضاقت {صدورهم} عن {أن يقاتلوكم} مع قومهم {أو يقاتلوا قومهم} معكم أي ممسكين عن قتالكم وقتالهم فلا تتعرضوا إليهم بأخذ ولا قتل وهذا ما بعده منسوخ بآية السيف {ولو شاء الله} تسليطهم عليكم {لسلطهم عليكم} بأن يقّوي قلوبهم {فلقاتلوكم} ولكنه لم يشأه فألقى في قلوبهم الرعب {فإن اعتزلوكم فلم يقاتلوكم وألقوا إليكم السَّلَمَ} الصلح أي انقادوا {فما جعل الله لكم عليهم سبيلا} طريقا بالأخذ والقتال.