Short answer
No. Your life is a gift and a trust from Allah (﷾), and it matters to Him even when it feels worthless to you. The Qur'an tells believers not to kill themselves, and gives the reason in the same verse: Allah (﷾) has been Most Merciful to them (4:29). If you are thinking of ending your life, please talk to someone today. Call Samaritans on 116 123 in the UK and Ireland, or 988 in the US and Canada. Elsewhere, findahelpline.com lists free lines. In danger, call your local emergency number. Islam does not ask you to carry pain alone. The Prophet (ﷺ) said Allah (﷾) made no illness without also making its treatment, so seeing a doctor or counsellor is part of faith, not a failure of it. The Qur'an promises that with every hardship there is relief (94:5-6), and it tells everyone never to despair of Allah's (﷾) mercy (39:53).
Full explanation
Your life is a trust from Allah (﷾)
The Qur'an tells believers not to kill or destroy themselves, and gives the reason in the same breath: Allah (﷾) has been Most Merciful to them. It also tells them not to throw themselves into ruin with their own hands. A person's life is not his to end. It was given by Allah (﷾), and it is held in trust until Allah (﷾) takes it back.
“O ye who believe! Eat not up your property among yourselves in vanities: But let there be amongst you Traffic and trade by mutual good-will: Nor kill (or destroy) yourselves: for verily Allah hath been to you Most Merciful!”
“And spend of your substance in the cause of Allah, and make not your own hands contribute to (your) destruction; but do good; for Allah loveth those who do good.”
Pain is not a sign that Allah (﷾) has left you
The Prophet (ﷺ) spoke of what reaches a believer: tiredness, illness, sorrow, sadness, hurt or distress, even the prick of a thorn. By each of these, he said, Allah (﷾) wipes away some of his sins. The Qur'an says people will be tested with fear, hunger and loss. It gives good news to those who are patient. It repeats a promise twice so that no one misses it: with every difficulty there is relief.
Abu Sa'id al-Khudri and Abu Hurayra report that the Prophet (ﷺ) said no tiredness, illness, sorrow, sadness, hurt or distress reaches a Muslim, not even the prick of a thorn, without Allah wiping away some of his sins because of it.
“Be sure we shall test you with something of fear and hunger, some loss in goods or lives or the fruits (of your toil), but give glad tidings to those who patiently persevere, Who say, when afflicted with calamity: "To Allah We belong, and to Him is our return":- They are those on whom (Descend) blessings from Allah, and Mercy, and they are the ones that receive guidance.”
“So, verily, with every difficulty, there is relief: Verily, with every difficulty there is relief.”
What to pray when life feels too heavy
The Prophet (ﷺ) knew that people would sometimes wish they were dead. He told them not to wish for death because of some harm that has struck them. If a person must say something, he taught them to pray: "O Allah, keep me alive as long as life is better for me, and take me when death is better for me." The prayer hands the decision back to Allah (﷾), who knows what lies ahead.
Anas reports that the Prophet (ﷺ) said none of you should wish for death because of a harm that has struck him. If he must wish, let him say: "O Allah, keep me alive as long as life is better for me, and take me when death is better for me."
Getting help is part of faith
The Prophet (ﷺ) said Allah (﷾) created no disease without also creating its treatment. Depression and other illnesses of the mind are illnesses like any other. Seeing a doctor, taking treatment and talking to a counsellor all follow the Prophet's (ﷺ) teaching. Prayer and the remembrance of Allah (﷾) bring comfort, and the Qur'an says hearts find rest in it. They go together with treatment, not in place of it.
Abu Hurayra reports that the Prophet (ﷺ) said God has not sent down any disease without also sending down its cure.
“"Those who believe, and whose hearts find satisfaction in the remembrance of Allah: for without doubt in the remembrance of Allah do hearts find satisfaction.”
Allah (﷾) is near
Whoever you are, you can speak to Allah (﷾) right now, in your own words. The Qur'an says: "When My servants ask thee concerning Me, I am indeed close (to them): I listen to the prayer of every suppliant when he calleth on Me" (2:186). It also says that Allah (﷾) "created Death and Life, that He may try which of you is best in deed" (67:2). Life is a test, and pain is part of it. The One who set the test knows what you are carrying, and He has not left you to carry it alone.
“When My servants ask thee concerning Me, I am indeed close (to them): I listen to the prayer of every suppliant when he calleth on Me: Let them also, with a will, Listen to My call, and believe in Me: That they may walk in the right way.”
“He Who created Death and Life, that He may try which of you is best in deed: and He is the Exalted in Might, Oft-Forgiving;-”
Allah's (﷾) mercy is wider than any sin
The Qur'an tells everyone who has wronged himself not to despair of Allah's (﷾) mercy, for He forgives all sins. A report in Sahih Muslim tells of a man who emigrated to Medina, fell ill there, and in his distress took his own life. His companion later saw him in a dream. The man said Allah (﷾) had forgiven him for his emigration, though his hands were still covered. When the Prophet (ﷺ) heard it, he prayed: "O Allah, forgive his hands too." Al-Nawawi, a scholar of hadith, drew a rule from it. A Muslim who takes his own life has done a grave wrong, but he is not a disbeliever, and his case rests with Allah (﷾). This is a comfort for families who have lost someone. It is never a reason for anyone to choose that path.
“Say: "O my Servants who have transgressed against their souls! Despair not of the Mercy of Allah: for Allah forgives all sins: for He is Oft-Forgiving, Most Merciful.”
Jabir reports that al-Tufayl ibn Amr emigrated to Medina with a man of his tribe, who fell ill there, was overcome by distress and took his own life. Al-Tufayl saw him in a dream in a good state, but with his hands covered. The man said Allah had forgiven him because of his emigration to the Prophet (ﷺ), but that he had been told what he had damaged himself would not be set right. When al-Tufayl told the Prophet (ﷺ), he prayed: O Allah, forgive his hands too.
Al-Nawawi says the hadith is proof of a great rule: whoever takes his own life, or commits any other sin, and dies without repenting, is not a disbeliever and is not declared certain of the Fire; his case rests with Allah's will. He adds that the hadith explains other reports whose outward wording seems to say such a person stays in the Fire for ever.
How seriously Islam takes it
Islam counts taking one's own life among the major sins, and the Prophet (ﷺ) warned of a severe punishment for it. The warning is there so that no one goes near it. Yet a Muslim who dies this way has not left Islam, and his case rests with Allah (﷾), as al-Nawawi explains. The Prophet (ﷺ) once left the funeral prayer over such a man himself, to warn others away, but his Companions prayed over him. Most scholars, among them Malik, Abu Hanifa and al-Shafi'i, hold that Muslims offer the funeral prayer over one who took his own life.
Al-Dhahabi's book of the major sins counts seventy, each with its proofs from the Qur'an and the Sunnah. The twenty-ninth is that a person kill himself (an yaqtul al-insan nafsahu).
Abu Hurayra reports that the Prophet (ﷺ) said whoever kills himself, whether by a fall, by poison or with a blade, will suffer the same in the Fire.
Al-Nawawi says the hadith is proof of a great rule: whoever takes his own life, or commits any other sin, and dies without repenting, is not a disbeliever and is not declared certain of the Fire; his case rests with Allah's will. He adds that the hadith explains other reports whose outward wording seems to say such a person stays in the Fire for ever.
Jabir ibn Samura reports that a man who had killed himself with broad arrowheads was brought to the Prophet (ﷺ), and he did not pray over him. Muslim places it under the chapter heading: leaving the funeral prayer for one who killed himself.
Jabir ibn Samura reports that a man killed himself with an arrowhead, and the Messenger of Allah (ﷺ) said that he himself would not pray over him (amma ana fa-la usalli 'alayh).
Al-Nawawi says the hadith is taken as proof by those who hold that no funeral prayer is offered over one who killed himself, the view of Umar ibn Abd al-Aziz and al-Awza'i. Al-Hasan, al-Nakha'i, Qatada, Malik, Abu Hanifa, al-Shafi'i and most scholars hold that the prayer is offered over him. They answer that the Prophet (ﷺ) did not pray over him himself in order to deter people from such an act, and the Companions prayed over him, as at first he left the prayer over a man who died in debt to deter people from careless borrowing.
Perspectives
The Islamic perspective
Life is a gift and a trust from Allah (﷾). Islam meets suffering with mercy, prayer, patience and treatment, and it tells no one to carry pain alone. Taking one's own life is a major sin, and the Prophet (ﷺ) warned against it severely. Yet a Muslim who dies this way is not a disbeliever, Muslims pray over him, and his case rests with Allah (﷾).
The Qur'an forbids believers to kill or destroy themselves.
Suicide is a major sin; al-Dhahabi counts a person killing himself among the major sins.
The Prophet (ﷺ) warned of a severe punishment in the Hereafter for whoever kills himself.
The Prophet (ﷺ) did not pray over a man who killed himself, to deter others. The Companions prayed over him, and most scholars hold that the funeral prayer is offered.
The Prophet (ﷺ) told people not to wish for death because of harm, and taught a prayer to say instead.
The Prophet (ﷺ) said Allah (﷾) created no disease without its treatment.
Al-Nawawi held that a Muslim who takes his own life is not a disbeliever. His case rests with Allah (﷾).