The Messenger of Allah ﷺ said, "Allah smiles upon two men, one of whom kills the other, yet both enter Paradise. One fights in the cause of Allah and is martyred, then Allah accepts the repentance of his killer, who embraces Islam, fights in the cause of Allah, and is himself martyred."
حدثنا أبو بكر بن أبي شيبة حدثنا وكيع عن سفيان عن أبي الزناد عن الأعرج
قال رسول الله ﷺ إن الله يضحك إلى رجلين يقتل أحدهما الآخر كلاهما دخل الجنة يقاتل هذا في سبيل الله فيستشهد ثم يتوب الله على قاتله فيسلم فيقاتل في سبيل الله فيستشهد
Muslim narrated it in the chapter on the Emirate, in the section explaining that two men, one of whom kills the other, may both enter Paradise, hadith no. 1890, from Ibn Abu Shayba and others, with this wording.