Regarding the statement of Allah Most High, "The penalty for those who wage war against Allah and His Messenger" [Maidah 5:33], he said, "This verse was revealed concerning the polytheists. Whoever among them repents before he is apprehended, no action may be taken against him. This verse does not apply to the Muslim man. So whoever kills, spreads corruption on earth, and wages war against Allah and His Messenger, then joins the disbelievers before being apprehended, that does not prevent the prescribed punishment from being carried out against him for what he committed."
أخبرنا زكريا بن يحيى قال حدثنا إسحق بن إبراهيم قال أنبأني علي بن الحسين بن واقد قال حدثني أبي قال حدثنا يزيد النحوي عن عكرمة
في قوله تعالى {إنما جزاء الذين يحاربون الله ورسوله} الآية قال نزلت هذه الآية في المشركين فمن تاب منهم قبل أن يقدر عليه لم يكن عليه سبيل وليست هذه الآية للرجل المسلم فمن قتل وأفسد في الأرض وحارب الله ورسوله ثم لحق بالكفار قبل أن يقدر عليه لم يمنعه ذلك أن يقام فيه الحد الذي أصاب
[Its chain of transmission is hasan] Abu Dawud narrated it in the Hudud, chapter on what has been said about waging war, no. 4372, from the hadith of Ali bin Husayn with the same wording, and it is also in Al-Kubra, no. 3509.