It is narrated from Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him): "In the blessed time of the Messenger of Allah (peace and blessings be upon him), a man would divorce his wife and (afterwards) say: I was only joking; or free his slave and say: I was only playing (jesting); or marry off his daughter and say: I was only joking. So the Messenger of Allah (peace and blessings be upon him) said: 'There are three things which, if a person says them even in jest, become effective and binding upon him: freeing a slave, divorce and marriage.' And in this connection Allah, the Blessed and Exalted, revealed this verse: (And do not take the verses of Allah in mockery)."
Also, in the narration of Imam al-Harith bin Muhammad bin Abi Usamah, it is narrated from Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him): "The Messenger of Allah (peace and blessings be upon him) said: 'Jesting (as an excuse) is not permissible in three things: divorce, marriage and freeing a slave; so whoever utters these words, they become (legally) established and binding.'"
Hadith Gradingمحدثین:سكت عنه البوصيري، إسناده ضعيف؛ لضعف إسماعيل بن مسلم المكي، ولانقطاعه بين الحسن وعبادة بن الصامت
Hadith Takhrij«إسماعيل بن مسلم المكي: ضعيف الحديث (التقريب) (من الحفظ)؛ الحسن البصري لم يسمع من عبادة (من الحفظ). والطريق الثانية فيها ابن لهيعة، وعبيد الله بن أبي جعفر لم يدرك عبادة.» «أخرجه مجمع الزوائد ومنبع الفوائد برقم: 7528، 7529»