The Messenger of Allah ﷺ said, "Allah smiles at two men, one of whom kills the other, yet both enter Paradise. One fights in the cause of Allah and is killed. Then Allah accepts the repentance of his killer, who then fights and is martyred."
أخبرنا محمد بن سلمة والحارث بن مسكين قراءة عليه وأنا أسمع عن ابن القاسم قال حدثني مالك عن أبي الزناد عن الأعرج
أن رسول الله ﷺ قال يضحك الله إلى رجلين يقتل أحدهما الآخر كلاهما يدخل الجنة يقاتل هذا في سبيل الله فيقتل ثم يتوب الله على القاتل فيقاتل فيستشهد
Bukhari narrated it, in the chapter "the disbeliever kills a Muslim, then embraces Islam, then goes on to act rightly afterward and is killed," Jihad, no. 2826, from the hadith of Malik, by this route. It is also in Al-Kubra, no. 4374, and in Muwatta (Yahya), 2/460.