It is narrated from Sayyiduna al-Harith bin Ziyad al-Sa'idi al-Ansari (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever loves the Ansar, Allah Almighty will love him when he meets Him (on the Day of Resurrection); and whoever hates the Ansar, Allah Almighty will be displeased with him and hate him when he meets Him."
Imam Abu Bakr bin Abi Shaybah, Ahmad bin Mani', Abu Ya'la al-Mawsili, and Ibn Hibban in his Sahih recorded this hadith.
The wording of Imam Ahmad bin Hanbal's narration is that Sayyiduna al-Harith bin Ziyad (may Allah be pleased with him) came to the Prophet (peace and blessings be upon him) on the day of the battle of the Trench (Khandaq) while he (peace and blessings be upon him) was taking the pledge of allegiance from people for the hijrah. He said: "O Messenger of Allah! Take the pledge from this man as well." He (peace and blessings be upon him) asked: "Who is this?" He said: "This is my paternal cousin Hawt bin Yazid (or Yazid bin Hawt)." The Messenger of Allah (peace and blessings be upon him) said: "I will not take the pledge (of hijrah) from you (the Ansar), for people emigrate to you; you do not emigrate to them. By the One in whose hand is my soul! No man meets Allah Almighty loving the Ansar except that Allah, the Blessed and Exalted, will meet him in a state of loving him; and no man meets Allah Almighty hating the Ansar except that Allah, the Blessed and Exalted, will meet him in a state of being displeased with him and hating him."