It is narrated from Sayyiduna Ali (may Allah be pleased with him) that he said: "I heard the Prophet (peace and blessings be upon him) saying: 'Love your friend moderately, for perhaps he may become your enemy one day; and dislike your enemy moderately, for perhaps he may become your friend one day.'"
(One of its narrators,) Yahya bin al-Fadl: I know of no criticism (jarh) or commendation (ta'dil) of him; however, these three imams narrated from him: Qadi Ahmad bin Ali, Imam Muhammad bin Khuzaymah and Imam Abu Arubah (may Allah have mercy on them).
And the narrations of Abu Amir al-Aqadi (Abd al-Malik bin Amr) are found in the "Sahihayn" (the two Sahihs).
And Harun al-Ahwazi was declared trustworthy (thiqah) by Yahya bin Ma'in (may Allah have mercy on him).
And Muslim bin Ibrahim narrated it from al-Hasan bin Abi Ja'far, from Ayyub, from Humayd bin Abd al-Rahman, from Sayyiduna Ali (may Allah be pleased with him), from the Prophet (peace and blessings be upon him).
Imam Abu Isa al-Tirmidhi (may Allah have mercy on him) said: "Al-Hasan bin Abi Ja'far narrated it, and it is a weak hadith of the Prophet (peace and blessings be upon him), narrated with a chain of his from Sayyiduna Ali (may Allah be pleased with him), whereas what is correct is that it is mawquf (from the Companion) on Sayyiduna Ali (may Allah be pleased with him)."
I (Imam Diya al-Din al-Maqdisi, may Allah have mercy on him) think that Imam al-Tirmidhi (may Allah have mercy on him) did not come across the chain of al-Aqadi, for al-Hasan bin Abi Ja'far cannot be used as proof; and Allah knows best.
Ibrahim al-Nakha'i (may Allah have mercy on him) narrated something similar through Alqamah bin Qays (may Allah have mercy on him) from Sayyiduna Ali (may Allah be pleased with him) as his own saying (mawquf).
Imam al-Daraqutni (may Allah have mercy on him) was asked about the hadith of Ubaydah from Sayyiduna Ali (may Allah be pleased with him): "Love your friend moderately" (to the end of the hadith), and he said: "It is a hadith that Dawud bin al-Zibriqan narrates from Hisham bin Hassan, from Rishdin, from Ubaydah, as the saying of Sayyiduna Ali (may Allah be pleased with him); and Harun bin Ibrahim al-Ahwazi differed from him and narrated it from Ibn Sirin, from Humayd bin Abd al-Rahman, from Sayyiduna Ali (may Allah be pleased with him) as marfu' (attributed to the Prophet (peace and blessings be upon him))." Abu Amir al-Aqadi narrated it (as marfu') from Harun, whereas Zayd bin al-Hubab narrated it from Harun, from Ibn Sirin, that the Messenger of Allah (peace and blessings be upon him) said; (that is,) it is mursal.
And Suwayd bin Amr al-Kalbi narrated it from Hammad bin Salamah, from Ayyub, from Ibn Sirin, from Sayyiduna Abu Hurayrah (may Allah be pleased with him), from the Prophet (peace and blessings be upon him); whereas al-Hasan bin Abi Ja'far differed from him and narrated it from Ayyub, from Humayd bin Abd al-Rahman al-Himyari, without mentioning Ibn Sirin, and he narrated it from Sayyiduna Ali (may Allah be pleased with him) as marfu'. And Allah knows best what is correct.
Related hadith on this topic