Sayyiduna Hasan bin Ali (may Allah be pleased with them both) narrates from Sayyiduna Ammar bin Yasir (may Allah be pleased with him) that he said: "A beggar came and stood by Sayyiduna Ali bin Abi Talib (may Allah be pleased with him) while he was in the bowing (ruku') of a voluntary prayer. He took off his ring and gave it to the beggar. Then the beggar came to the Messenger of Allah (peace and blessings be upon him) and informed him (peace and blessings be upon him) of what had happened, and this verse was revealed to the Prophet (peace and blessings be upon him): 'Your ally is none but Allah and His Messenger and those who believe - those who establish prayer and give zakah while they bow (in worship).' The Messenger of Allah (peace and blessings be upon him) recited it and then said: 'Whoever I am his mawla (patron), Ali is his mawla. O Allah, befriend whoever befriends him and be hostile to whoever is hostile to him.'"
Imam al-Tabarani (may Allah have mercy on him) said: "This hadith is narrated from Sayyiduna Ammar bin Yasir (may Allah be pleased with him) only with this chain; Khalid bin Yazid is alone in narrating it."