إﻻ الذين يصلون إلى قوم بينكم وبينهم ميثاق
Except those who join a group, between you and whom there is a treaty (of peace),
meaning, except those who join and take refuge with a people with whom you have a pact of peace, or people of Dhimmah, then treat them as you treat the people with whom you have peace.
This is the saying of As-Suddi, Ibn Zayd and Ibn Jarir.
In his Sahih, Al-Bukhari recorded the story of the treaty of Al-Hudaybiyyah, where it was mentioned that;
whoever liked to have peace with Quraysh and conduct a pact with them, then they were allowed. Those who liked to have peace with Muhammad and his Companions and enter a pact with them were allowed.
It was reported that Ibn Abbas said that;
this Ayah was later abrogated by Allah's statement,
فٳذا انسلخ اﻻشهر الحرم فاقتلوا المشركين حيث وجدتموهم
Then when the Sacred Months have passed, kill the idolators wherever you find them. (9:5)
Allah said,
أو جاووكم حصرت صدورهم
or those who approach you with their breasts restraining,
referring to another type of people covered by the exclusion from fighting. They are those who approach the Muslims with hesitation in their hearts because of their aversion to fighting the Muslims.
أن يقاتلونكم أو يقاتلوا قومهم
from fighting you as well as fighting their own people.
They do not have the heart to fight with the Muslims against their own people. Therefore, they are neither with nor against Muslims.
ولو شاء الله لسلطهم عليكم فلقاتلوكم
Had Allah willed, indeed He would have given them power over you, and they would have fought you.
meaning, it is from Allah's mercy that He has stopped them from fighting you.
فٳن اعتزلوكم فلم يقاتلوكم وألقوا إليكم السلم
So, if they withdraw from you, and fight not against you, and offer you peace,
meaning, they revert to peace.
فما جعل الله لكم عليهم سبيﻼ
then Allah has opened no way for you against them.
you do not have the right to kill them, as long as they take this position.
This was the position of Banu Hashim (the tribe of the Prophet), such as Al-Abbas, who accompanied the idolators in the battle of Badr, for they joined the battle with great hesitation. This is why the Prophet commanded that Al-Abbas not be killed, but only captured.
Allah's statement,