Ali was informed that a certain man saw no harm in temporary marriage. Ali said, "You are mistaken. The Messenger of Allah ﷺ forbade it, along with the meat of domestic donkeys, on the day of Khaybar."
أخبرنا عمرو بن علي قال حدثنا يحيى عن عبيد الله بن عمر قال حدثني الزهري
أن عليا بلغه أن رجلا لا يرى بالمتعة بأسا فقال إنك تائه إنه نهى رسول الله ﷺ عنها وعن لحوم الحمر الأهلية يوم خيبر
This hadith was related by Bukhari in the book of Maghazi, chapter on the Battle of Khaybar, hadith no. 4216, from the hadith of Yahya Qattan, and so on, hadith no. 1407, from the hadith of Ubaydullah. Muslim related it in the book of Nikah, chapter on temporary marriage and the explanation that it was permitted and then abrogated, from Ibn Umar. It is also found in Kubra, hadith no. 5547.