We came with the Messenger of Allah ﷺ on the pilgrimage he performed. At a point along the way he stopped, and the call went out for the congregational prayer. Then he took Ali by the hand and said, "Am I not closer to the believers than they are to themselves?"They replied, "Yes, indeed."He said, "Am I not closer to every believer than he is to himself?"They replied, "Yes, indeed."He said, "Then this man is the patron of whoever takes me as his patron. O Allah, befriend whoever befriends him, and oppose whoever opposes him."
حدثنا علي بن محمد حدثنا أبو الحسين أخبرني حماد بن سلمة عن علي بن زيد بن جدعان عن عدي بن ثابت
أقبلنا مع رسول الله ﷺ في حجته التي حج فنزل في بعض الطريق فأمر الصلاة جامعة فأخذ بيد علي رضي الله عنه فقال ألست أولى بالمؤمنين من أنفسهم قالوا بلى قال ألست أولى بكل مؤمن من نفسه قالوا بلى قال فهذا ولي من أنا مولاه اللهم وال من والاه اللهم عاد من عاداه
Sourcing, [its chain of transmission is daif] Ahmad: 4/281 narrated it from the hadith of Hammad in this manner, and Busiri graded it daif.Ali bin Zayd bin Jadan is daif (Taqrib). The core of the hadith, "Whoever's master I am, Ali is his master," is sahih and mutawatir. Refer to Nazm al-Mutanathir and other sources.