A Muslim who turns back from Islam and returns to disbelief is called a مرتد
(murtad) in Islamic jurisprudence.
The basis of this is the usage of the term in the Quran:
ومن يرتدد منكم عن دينه فيمت وهو كافر فأولئك حبطت أعمالهم في الدنيا والآخرة
And whoever of you reverts from his religion [to disbelief] and dies while he is a disbeliever - for those, their deeds have become worthless in this world and the Hereafter
— Quran 2:217
يردوكم بعد إيمانكم كافرين
they would turn you back, after your belief, [to being] unbelievers.
— Quran 3:100
There is no condition of treason, tarnishing the image of Islam or fighting or harming Muslims. Such a requisite is neither present in the Quranic usage of the term, nor in hadith that detail the rules about them, nor do any of the jurists impose such a condition.
وتختص الردة - في الاصطلاح الفقهي - بالكفر بعد الإسلام. وكل مسلم ارتد فإنه يقتل إن لم يتب، إلا المرأة عند الحنفية فإنها تحبس
Apostasy is defined - in the terminology of jurisprudence - as Kufr after Islam. And every Muslim who apostatizes will be executed if he does not repent, except a woman near the Hanafis for she will be imprisoned.
— Mawsoo‘ah al-Fiqhiyyah
Regarding the legal punishment for apostasy: the person is imprisoned and asked to repent and revert to Islam. When a set period of time elapses on them in this state and they continue to refuse, then they are executed. If they revert, they are set free. The Hanafis do not execute a female apostate and would keep her imprisoned until she reverts, whereas the others do not make a difference between male and female apostates.
وإذا ارتد المسلم عن الإسلام والعياذ بالله عرض عليه الإسلام فإن كانت له شبهة كشفت عنه " لأنه عساه اعترته شبهة فتزاح وفيه دفع شره بأحسن الأمرين
If a Muslim leaves Islam then he should be asked to revert to Islam. If he has any doubts then these should be resolved, because it is possible that some doubt has arisen and this should be removed so that the better of the two outcomes is chosen (repentance and return to Islam rather than execution).
ويحبس ثلاثة أيام فإن أسلم وإلا قتل
He should be imprisoned for three days, after which if he accepts Islam then he is freed, otherwise he is to be killed.
— الهداية في شرح بداية by Marghinani
The punishment of apostasy is corroborated in the Quran, see my answer on: Death penalty for Apostasy according to Quran?
Some ahadith which form the basis of the punishment for apostasy include:
من بدل دينه فاقتلوه
Whoever changes his religion, kill him.
— Bukhari
من غير دينه فاضربوا عنقه
If someone changes his religion strike his neck.
— Muwatta Malik
لا يحل دم امرئ مسلم إلا بإحدى ثلاث ... والتارك لدينه المفارق للجماعة
It is not permissible to spill the blood of a Muslim except in three [instances]: ... and the one who forsakes his religion and separates from the community.
— Muslim
لا يحل دم امرئ مسلم إلا ... كفر بعد إسلامه
It is not permissible to shed the blood of a Muslim, except ... one who reverted to Kufr after becoming Muslim
— Nisai
وإذا رجل عنده موثق قال ما هذا قال هذا كان يهوديا فأسلم ثم راجع دينه دين السوء فتهود قال لا أجلس حتى يقتل قضاء الله ورسوله
There was a man bound hand and foot as a prisoner. Mu'adh said: Who is this? Abu Musa said: He was a Jew. He embraced Islam. Then he reverted to his false religion and became a Jew. Mu'adh said: I won't sit until he is killed according to the decree of Allah and His Messenger (ﷺ)
— Muslim
عن معاذ بن جبل ، أن رسول الله صلى الله عليه وسلم قال له حين بعثه إلى اليمن : أيما رجل ارتد عن الإسلام فادعه ، فإن تاب فاقبل منه ، وإن لم يتب فاضرب عنقه
Muadh bin Jabal narrated that when the Messenger of Allah ﷺ sent him to Yemen he said:
The person who leaves Islam, invite him to return to Islam. If he repents then accept his conversion. If he does not repent then strike his neck.
— Mu'jam Al Kabir of Tabarani
سمعت رسول الله صلى الله عليه وسلم يقول لهما حين قرآ كتاب مسيلمة " ما تقولان أنتما " قالا نقول كما قال . قال " أما والله لولا أن الرسل لا تقتل لضربت أعناقكما
I heard the Messenger of Allah (ﷺ) say when he read the letter of Musaylimah: What do you believe yourselves? They said: We believe as he believes. He said: I swear by Allah that were it not that messengers are not killed, I would cut off your heads.
— Sunan Abi Dawud
There is Ijma (consensus) on executing apostates:
وأجمع أهل العلم على وجوب قتل المرتد . وروي ذلك عن أبي بكر ، وعمر وعثمان ، وعلي ، ومعاذ ، وأبي موسى ، وابن عباس ، وخالد ، وغيرهم ، ولم ينكر ذلك ، فكان إجماعا
There is the consensus of the people of knowledge on the obligation of killing an apostate (male). This has been narrated on the authority of Abu Bakr, Umar, Usman, Ali, Mudath, Abu Musa, Ibn Abbas, Khalid, and others. None have denied it, hence it is a matter of consensus.
— المغني by Ibn Qudaymah
فيه وجوب قتل المرتد ، وقد أجمعوا على قتله ، لكن اختلفوا في استتابته ، هل هي واجبة أم مستحبة ؟ وفي قدرها وفي قبول توبته ، وفي أن المرأة كالرجل في ذلك أم لا ؟
On the obligation of killing an apostate. And there is consensus on killing them. But there is difference on asking them to repent, whether it is obligatory recommended, the number of times that they must be asked to repent, whether their repentance is accepted and whether the rules for a female are different from a male.
— شرح النووي على مسلم by Nawawi
واتفق الأئمة الأربعة عليهم رحمه الله تعالى: على أن من ثبت ارتداده عن الإسلام والعياذ بالله وجب قتله
The four Imams are agreed that if it is proven that a man has reverted from Islam then it is obligatory to kill him
— الفقه على المذاهب الأربعة by Jaziri
وقد اتفق العلماء على وجوب قتل المرتد، لقوله صلّى الله عليه وسلم: «من بدل دينه فاقتلوه» (2) وقوله عليه السلام: «لا يحل دم امرئ مسلم إلا بإحدى ثلاث: الثيب الزاني، والنفس بالنفس،
والتارك لدينه المفارق للجماعة» (3)۔
The Ulema are agreed on the obligation of killing an apostate, because of the saying of the Prophet: "Whoever changes his religion, kill him." (2) and "It is not permissible to spill the blood of a Muslim except in three [instances]: the married person who commits adultery, a life for a life, and the one who forsakes his religion and separates from the community." (3)
وأجمع أهل العلم على وجوب قتل المرتد، وكذا تقتل المرأة المرتدة عند جمهور العلماء غير الحنفية
There is consensus of the people of knowledge on the obligation of killing a (male) apostate; and on killing a female apostate (there is consensus) of the majority, except the Hanafis.
— الفقه الإسلامي وأدلته by Zuhayli