We used to practice withdrawal during the time of the Messenger of Allah ﷺ while the Quran was still being revealed.
حدثنا هارون بن إسحق الهمداني حدثنا سفيان عن عمرو عن عطاء
كنا نعزل على عهد رسول الله ﷺ والقرآن ينزل
Sourced by Bukhari, Nikah, chapter on coitus interruptus, no. 5208, and Muslim, Nikah, chapter on the ruling on coitus interruptus, no. 1440, from the hadith of Sufyan through this chain.