Some people from among the polytheists had committed many murders and engaged in much fornication. They came to Muhammad ﷺ and said, "What you are saying and calling us to is indeed good, if only you could tell us that there is an atonement for what we have done."So the verse was revealed, "And those who do not invoke another god alongside Allah, nor kill the soul which Allah has forbidden except by right, nor commit fornication" [Furqan 25:68], and there was also revealed, "Say, My servants who have transgressed against themselves, do not despair of the mercy of Allah" [Zumar 39:53].
أن ناسا من أهل الشرك كانوا قد قتلوا وأكثروا، وزنوا وأكثروا فأتوا محمدا ﷺ فقالوا: إن الذي تقول وتدعو إليه لحسن لو تخبرنا أن لما عملنا كفارة، فنزلت {والذين لا يدعون مع الله إلها آخر ولا يقتلون النفس التي حرم الله إلا بالحق ولا يزنون} [الفرقان: ٦٨]، ونزل {قل يعبادي الذين أسرفوا على أنفسهم لا تقنطوا من رحمة الله} [الزمر: ٥٣].
Bukhari reported it in the tafsir (4810), and Muslim in the book of faith (122), both from Ibn Jurayj, who said, Yaala bin Muslim informed me that he heard Saeed bin Jubayr narrating from Ibn Abbas, and he mentioned it.