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:9:1

˹This is a declaration of˺ disassociation, from Allah and His Messenger, to those with whom you had made a treaty among the polytheists.  

This is: A declaration of immunity from God and His Messenger to, reach, the idolaters with whom you made a pact, a pact for an indefinite period of time, or one for ˹a period of˺ less than, or more than, four months; the annulment of the pact shall be as God mentions in His saying:
القرآن:٩:١

بَرَآءَةٌ مِّنَ ٱللَّهِ وَرَسُولِهِۦٓ إِلَى ٱلَّذِينَ عَٰهَدتُّم مِّنَ ٱلْمُشْرِكِينَ  

هذه {براءة من الله ورسوله} وأصله {إلى الذين عاهدتم من المشركين} عهدا مطلقا أو دون أربعة أشهر أو فوقها ونص العهد بما يذكر في قوله.