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:3:122

When two parties among you were about to lose courage, but Allah was their ally; and upon Allah the believers should rely.  

When (idh, substitutes for the previous idh) two parties of you, the Banū Salima and the Banū Hāritha, the two flanks of the army, were about to lose heart, ˹about˺ to shrink from the battle and retreat, after ‘Abd Allāh b. Ubayy, the hypocrite, and his companions began to retreat. He ˹Ibn Ubayy˺ said, ‘Why should we get ourselves and our children killed?’ and he also said to Abū Jābir al-Salamī — who had said to him, ‘I implore you by God for your Prophet’s sake and yours’ — ‘If we knew how to fight, we would follow you!’ But God then made them ˹the Banū Salima and the Banū Hāritha˺ steadfast and they did not abandon ˹the field˺; and God was their Protector, their Helper, and let the believers rely on God, let them place their trust in Him and none other.
القرآن:٣:١٢٢

إِذْ هَمَّتْ طَائِفَتَانِ مِنْكُمْ أَنْ تَفْشَلَا وَاللَّهُ وَلِيُّهُمَا ۗ وَعَلَى اللَّهِ فَلْيَتَوَكَّلِ الْمُؤْمِنُونَ  

{إذا} بدل من إذ قبله {همت طائفتان منكم} بنو سلمة وبنو حارثة جناحا العسكر {أن تفشلا} تجبنا عن القتال وترجعا لما رجع عبد الله بن أبيّ المنافقُ وأصحابه وقال: عَلام نقتلُ أنفسنا وأولادنا وقال لأبي جابر السمي القائل له أنشدكم الله في نبيكم وأنفسكم لو نعلم قتالا لا تبعناكم فثبتهما الله ولم ينصرفا {والله وليهما} ناصرهما {وعلى الله فليتوكل المؤمنون} ليثقوا به دون غيره.