(4) باب الْحِيلَةِ فِي النِّكَاحِ
Narrated Muhammad bin `Ali:
`Ali was told that Ibn `Abbas did not see any harm in the Mut'a marriage. `Ali said, "Allah's Messenger (ﷺ) forbade the Mut'a marriage on the Day of the battle of Khaibar and he forbade the eating of donkey's meat." Some people said, "If one, by a tricky way, marries temporarily, his marriage is illegal." Others said, "The marriage is valid but its condition is illegal."
Reference: Sahih al-Bukhari 6961
In-book reference: Book 90, Hadith 8
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 9, Book 86, Hadith 91