Allah mentioned His favor on the Prophet , in that He aided him with believers, the Muhajirin and the Ansar,
﴿هُوَ الَّذِى أَيَّدَكَ بِنَصْرِهِ وَبِالْمُؤْمِنِينَوَأَلَّفَ بَيْنَ قُلُوبِهِمْ﴾
(He it is Who has supported you with His help and with the believers. And He has united their hearts.)
The Ayah says, `it is Allah who gathered the believers' hearts, believing, obeying, aiding and supporting you -- O Muhammad,'
﴿لَوْ أَنفَقْتَ مَا فِى الاٌّرْضِ جَمِيعاً مَّآ أَلَّفْتَ بَيْنَ قُلُوبِهِمْ﴾
(If you had spent all that is in the earth, you could not have united their hearts.) because of the enmity and hatred that existed between them. Before Islam, there were many wars between the Ansar tribes of Aws and Khazraj, and there were many causes to stir unrest between them. However, Allah ended all that evil with the light of faith,
﴿وَاذْكُرُواْ نِعْمَةَ اللَّهِ عَلَيْكُمْ إِذْ كُنتُم أَعْدَآءً فَأَلَّفَ بَيْنَ قُلُوبِكُمْ فَأَصْبَحْتُم بِنِعْمَتِهِ إِخْوَاناً وَكُنتُمْ عَلَى شَفَا حُفْرَةٍ مِّنَ النَّارِ فَأَنقَذَكُمْ مِّنْهَا كَذلِكَ يُبَيِّنُ اللَّهُ لَكُمْ ءَايَـتِهِ لَعَلَّكُمْ تَهْتَدُونَ﴾
(And remember Allah's favor on you, for you were enemies one to another, but He united your hearts, so that, by His grace, you became brethren, and you were on the brink of a pit of Fire, and He saved you from it. Thus Allah makes His Ayat clear to you, that you may be guided.) ﴿3:103﴾
In the Two Sahihs, it is recorded that when the Messenger of Allah gave a speech to the Ansar about the division of war booty collected in the battle of Hunayn, he said to them,
«يَا مَعْشَرَ الْأَنْصَارِ أَلَمْ أَجِدْكُمْ ضُلَّالًا فَهَدَاكُمُ اللهُ بِي، وَعَالَةً فَأَغْنَاكُمُ اللهُ بِي، وَكُنْتُمْ مُتَفَرِّقِينَ فَأَلَّفَكُمُ اللهُ بِي»
(O Ansar! Did I not find you misguided and Allah guided you by me, poor and Allah enriched you by me, and divided and Allah united you by me) Every question the Prophet asked them, they said, "Truly, the favor is from Allah and His Messenger.'' Allah said,
﴿وَلَـكِنَّ اللَّهَ أَلَّفَ بَيْنَهُمْ إِنَّهُ عَزِيزٌ حَكِيمٌ﴾
(But Allah has united them. Certainly He is All-Mighty, All-Wise.)
He is the Most Formidable, and the hopes of those who have trust in Him, never end unanswered; Allah is All-Wise in all of His decisions and actions.
﴿يَـأَيُّهَا النَّبِىُّ حَسْبُكَ اللَّهُ وَمَنِ اتَّبَعَكَ مِنَ الْمُؤْمِنِينَ - يَـأَيُّهَا النَّبِىُّ حَرِّضِ الْمُؤْمِنِينَ عَلَى الْقِتَالِ إِن يَكُن مِّنكُمْ عِشْرُونَ صَـبِرُونَ يَغْلِبُواْ مِاْئَتَيْنِ وَإِن يَكُنْ مُّنكُمْ مِّاْئَةٌ يَغْلِبُواْ أَلْفًا مِّنَ الَّذِينَ كَفَرُواْ بِأَنَّهُمْ قَوْمٌ لاَّ يَفْقَهُونَ - الَـنَ خَفَّفَ اللَّهُ عَنكُمْ وَعَلِمَ أَنَّ فِيكُمْ ضَعْفاً فَإِن يَكُن مِّنكُمْ مِّاْئَةٌ صَابِرَةٌ يَغْلِبُواْ مِاْئَتَيْنِ وَإِن يَكُن مِّنكُمْ أَلْفٌ يَغْلِبُواْ أَلْفَيْنِ بِإِذْنِ اللَّهِ وَاللَّهُ مَعَ الصَّـبِرِينَ ﴾
(64. O Prophet! Allah is sufficient for you and for the believers who follow you.) (65. O Prophet! Urge the believers to fight. If there are twenty steadfast persons among you, they will overcome two hundred, and if there be a hundred steadfast persons they will overcome a thousand of those who disbelieve, because they (the disbelievers) are people who do not understand.) (66. Now Allah has lightened your (task), for He knows that there is weakness in you. So if there are of you a hundred steadfast persons, they shall overcome two hundred, and if there are a thousand of you, they shall overcome two thousand by the leave of Allah. And Allah is with the patient.)