When the people who spread the slander said what they said about her, the Prophet ﷺ said, "If you are innocent, Allah will clear you, and if you have fallen into some sin, then seek Allah's forgiveness and turn to Him in repentance."Aisha said, "By Allah, I could find no example for myself except Yusuf's father, 'So patience is beautiful, and Allah is the one whose help is sought against what you describe'" [Yusuf 12:18].Then Allah sent down, "Indeed, those who brought forth the slander are a group among you. Do not think it evil for you, rather it is good for you. Every one of them will bear the sin he has earned, and the one who took the greater part in it will have a mighty punishment" [Nur 24:11], the ten verses.
حين قال لها أهل الإفك ما قالوا… قال النبي ﷺ: إن كنت بريئة، فسيبرئك الله، وإن كنت ألممت بذنب، فاستغفري الله وتوبي إليه قلت: إني والله لا أجد مثلا إلا أبا يوسف{فصبر جميل والله المستعان على ما تصفون} وأنزل الله {إن الذين جاءو بالإفك عصبة منكم لا تحسبوه شرا لكم بل هو خير لكم لكل أمري منهم ما أكتسب من الإثم والذي تولى كبره منهم له عذاب عظيم} العشر الآيات.
Bukhari narrated it in the tafsir chapter (4690), and Muslim in the chapter on repentance (2770), both through Yunus bin Yazid Ayli, who said, "I heard Zuhri, who said, I heard Urwa bin Zubayr, Saeed bin Musayab, Alqama bin Waqqas, and Ubaydullah bin Abdullah, from Ayesha," and he mentioned it. The wording given is that of Bukhari, while Muslim's version is lengthy.