I believe he traced it back to the Prophet ﷺ, who said, "Love your beloved moderately, for he may one day become the one you detest, and detest the one you dislike moderately, for he may one day become your beloved."
حدثنا أبو كريب حدثنا سويد بن عمرو الكلبي عن حماد بن سلمة عن أيوب عن محمد بن سيرين
أراه رفعه قال أحبب حبيبك هونا ما عسى أن يكون بغيضك يوما ما وأبغض بغيضك هونا ما عسى أن يكون حبيبك يوما ما
No references are available.
[Its isnad is hasan]. Ibn Adi narrated it in 2/712, and Tamam in al-Fawaid 2/209, hadith 1544, from the hadith of Abu Kurayb, through this route.The hadith of Hasan bin Abu Jafar is found with Tamam Razi in his Fawaid 2/206, hadith 1541, and its chain is daif.The hadith of Ali is found with Bukhari in Adab al-Mufrad, hadith 1321, and it is mawquf, and its chain is daif, Muhammad bin Ubayd Kindi and his father are both of unknown status.The hadith has corroborating narrations, but all of them are daif.