When Allah granted His Messenger ﷺ the spoils of war on the day of Hunayn, he distributed shares among the people, giving to those whose hearts were to be reconciled, but he gave nothing to the Ansar. They felt some resentment, since they had not received what others had received. So he addressed them, saying, "Company of the Ansar, did I not find you astray, and Allah guided you through me? And you were divided, and Allah united you through me? And you were poor, and Allah enriched you through me? And you were poor, and Allah enriched you through me?"Each time he said something, they replied, "Allah and His Messenger have shown the greatest favor."...the hadith continues.
لما أفاء الله على رسوله ﷺ يوم حنين، قسم في الناس في المؤلفة قلوبهم، ولم يعط الأنصار شيئا، فكأنهم وجدوا إذ لم يصبهم ما أصاب الناس، فخطبهم، فقال: يا معشر الأنصار! ألم أجدكم ضلالا، فهداكم الله بي؟ وكنتم متفرقين، فألفكم الله بي؟ وعالة فأغناكم الله بي؟ وعالة فأغناكم الله بي؟ كلما قال شيئا، قالوا: الله ورسوله أمن… الحديث.
Bukhari related it in the Book of Military Expeditions (4330), and Muslim in the Book of Zakat (430), both through Amr bin Yahya bin Umara, from Abbad bin Tamim, from Abdullah bin Zayd, who narrated it. The wording given here is Bukhari's, and Muslim's wording is similar.