He traced it back to the Prophet ﷺ, who said, "Allah says, 'I am the third of two partners as long as neither of them betrays the other. When one betrays the other, I depart from between them.'"
حدثنا محمد بن سليمان المصيصي حدثنا محمد بن الزبرقان عن أبي حيان التيمي عن أبيه
رفعه قال إن الله يقول أنا ثالث الشريكين ما لم يخن أحدهما صاحبه فإذا خانه خرجت من بينهما
No references are available.
Its chain of transmission is hasan. Daraqutni reported it, 3/34, hadith 2910, from the hadith of Muhammad bin Sulayman Masissi through this route, and Hakim graded it sahih, 2/52, and Dhahabi agreed with him, and it was criticized in a way that does not detract from it.