It is narrated from Sayyiduna Ali (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said on the occasion of Ghadir Khumm: "Whoever I am the master of, Ali is also his master." Later, people added to this: "O Allah! Be the friend of whoever is his friend, and be the enemy of whoever is his enemy."
Hadith Referenceمسند احمد / مسند الخلفاء الراشدين / 1311
Hadith Gradingحکم دارالسلام:صحيح لغيره، وهذا إسناد ضعيف لضعف نعيم بن حكيم ولجهالة أبى مريم