He was one of the three whose repentance was accepted.Kaab bin al-Ashraf used to satirize the Prophet ﷺ in verse and incite the disbelievers of Quraysh against him. When the Prophet ﷺ arrived in Medina, its people were a mixture of Muslims, polytheists who worshipped idols, and Jews. They used to harm the Prophet ﷺ and his companions, so Allah commanded His Prophet to be patient and forgiving. It was concerning them that Allah revealed, "And you shall certainly hear from those who were given the Scripture before you" [Aal Imran 3:186].When Kaab bin al-Ashraf refused to stop harming the Prophet ﷺ, the Prophet ﷺ ordered Saad bin Muaz to send a group of men to kill him. Saad sent Muhammad bin Maslama, and the story of the killing was mentioned.When they had killed him, the Jews and the polytheists were alarmed and came to the Prophet ﷺ the next morning, saying, "Our companion was attacked at night and killed."The Prophet ﷺ then reminded them of what Kaab had been saying, and he invited them to enter into a written agreement that they would abide by its terms. So the Prophet ﷺ drew up a document between himself, them, and the Muslims at large.
حدثنا محمد بن يحيى بن فارس أن الحكم بن نافع حدثهم قال أخبرنا شعيب عن الزهري
وكان أحد الثلاثة الذين تيب عليهم وكان كعب بن الأشرف يهجو النبي ﷺ ويحرض عليه كفار قريش وكان النبي ﷺ حين قدم المدينة وأهلها أخلاط منهم المسلمون والمشركون يعبدون الأوثان واليهود وكانوا يؤذون النبي ﷺ وأصحابه فأمر الله عز وجل نبيه بالصبر والعفو ففيهم أنزل الله {ولتسمعن من الذين أوتوا الكتاب من قبلكم} الآية فلما أبى كعب بن الأشرف أن ينزع عن أذى النبي ﷺ أمر النبي ﷺ سعد بن معاذ أن يبعث رهطا يقتلونه فبعث محمد بن مسلمة وذكر قصة قتله فلما قتلوه فزعت اليهود والمشركون فغدوا على النبي ﷺ فقالوا طرق صاحبنا فقتل فذكر لهم النبي ﷺ الذي كان يقول ودعاهم النبي ﷺ إلى أن يكتب بينه كتابا ينتهون إلى ما فيه فكتب النبي ﷺ بينه وبينهم وبين المسلمين عامة صحيفة
[Its isnad is daif]. Bayhaqi narrated it in Dalail Nubuwwah 3/198, from the hadith of Abu Dawud, by the same route. The hadith has corroborating narrations. Zuhri is a mudallis narrator, and he narrated it using "an" (indicating possible concealment in the chain).