"Allah does not forbid you from those who do not fight you because of religion and do not expel you from your homes - from being righteous toward them" by maintaining ties, "and acting justly toward them," meaning: being fair with them regarding your wealth. "Indeed, Allah loves those who act justly," meaning those who are fair.
Muhammad said: It was said that the meaning of "acting justly toward them" is: being fair with them in regard to the fulfillment of covenants between you and them.
Yahya said: This was before the command to fight all the polytheists. Before being ordered to fight them, the Muslims consulted the Prophet regarding their polytheist relatives, wishing to maintain ties with them and treat them kindly, so Allah revealed this verse, according to the interpretation of al-Hasan.
﴿لَا يَنْهَاكُمُ اللَّهُ عَنِ الَّذِينَ لَمْ يُقَاتِلُوكُمْ فِي الدِّينِ وَلَمْ يُخْرِجُوكُمْ مِنْ دِيَارِكُمْ أَنْ تبروهم﴾ بالصلة ﴿وتقسطوا إِلَيْهِم﴾ أَي: تعدلوا إِلَيْهِم فِي أَمْوَالكُم ﴿إِن الله يحب المقسطين﴾ العادلين.
قَالَ مُحَمَّد: قيل: إِن معنى (تقسطوا إِلَيْهِم) (ل ٣٦٠): تعدلوا فِيمَا بَيْنكُم وَبينهمْ من الْوَفَاء بالعهد.
قَالَ يحيى: وَكَانَ هَذَا قبل أَن يُؤمر بِقِتَال الْمُشْركين كَافَّة، كَانَ الْمُسلمُونَ قبل أَن يُؤمر بقتالهم استشاروا النَّبِي فِي قرابتهم من الْمُشْركين أَن يصلوهم ويبروهم، فَأنْزل اللَّه هَذِه الْآيَة فِي تَفْسِير الْحسن.