How can there be a league, before Allah and His Messenger, with the Pagans, except those with whom ye made a treaty near the sacred Mosque? As long as these stand true to you, stand ye true to them: for Allah doth love the righteous.
These ayat from 7 to 24 were
revealed before the conquest of Makkah as mentioned in the introduction. At
that time when the Muslims were preparing for their final assault against the
Quraysh of Makkah, a difference of opinion arose between on the question
whether they fight against the Quraysh or not. Much of the debate was
initiated by the hypocrites of Madinah who discouraged the Muslims from
fighting against the Quraysh, for they said that the Quraysh were the
custodians of Makkah and if they fight, they would be shedding blood in the
Holy Sanctuary. Thus Allah (SWT) admonished them in this ayah and said that
how can there be a treaty with the idolaters on part of Allah (SWT) and His
Messenger (SAW), for they will never abide by it as they have so much hatred in
their hearts for the Muslims that if given the least opportunity, they will not even bother to honor their pledge. Thus Allah (SWT) stated that there can never be a treaty with the idolaters except for those with whom the Muslims
concluded a treaty at the Sacred Mosque i.e. the peace treaty of Hudaibiyah.
Then He commanded the Muslims to honor this treaty as long as they uphold
it, for He loves those who keep their promises.
Ahmad, Israr. (2012). Bayan ul Quran. 9-At-Tauba.pdf (islamicweblibrary.com)