It is narrated from Ubayy bin Ka'b (may Allah be pleased with him), he states: I asked, "O Messenger of Allah (ﷺ)! When one of us has intercourse and withdraws before ejaculation, what should he do?" The Prophet (ﷺ) said: "He should wash the part that touched the woman, then perform ablution and then offer prayer."
Hadith Referenceمسند الإمام الشافعي / كتاب الطهارة / 99
Hadith Takhrijاخرجہ البخاری: الغسل، باب غسل ما يصيب من رطوبة فرج المرأة: (293) ومسلم، الحيض، باب بيان أن الجماع كان في اول الاسلام لا يوجب الغسل الا ان ينزل المني (346)
It is narrated from Ubayy bin Ka'b (may Allah be pleased with him) that he used to say: Whoever has not ejaculated, ghusl is not obligatory upon him. Then, before his death, Ubayy bin Ka'b (may Allah be pleased with him) retracted from this statement.
Hadith Referenceمسند الإمام الشافعي / كتاب الطهارة / 100
Hadith Takhrijاسناده ضعیف بسبب ضعف شيخ الشافعی، لكنه صح من غير هذا الطريق اخرجه عبدالرزاق: (960) وابن أبي شيبة: (949) والبيهقي: 1/ 166
It is narrated from Ubayy bin Ka'b (may Allah be pleased with him) that he said: In the beginning of Islam, the use of water (i.e., performing ghusl) was required only upon the emission of semen, but later this was abandoned, and the command for ghusl was given merely upon the joining of the private parts.
Hadith Referenceمسند الإمام الشافعي / كتاب الطهارة / 101
Hadith Takhrijاخرجہ ابوداؤد الطهارة، باب في الاكسال (214)، (215) - والترمذی، الطهارة، باب ماجاء أن الماء من الماء: (10) (111)- وقال حسن صحيح و ابن ماجہ، الطهارة، باب ماجاء في وجوب الغسل اذا التقى الختانان (609) وصححہ ابن الجارود (91) وابن خزيمة (225, 226) وابن حبان (1166, 1170)