Allah the Almighty says,
And do not kill the soul which Allah has forbidden [to be killed] except by [legal] right. This has He instructed you that you may use reason [Qur`an 6: 151],
And do not kill yourselves [or one another]. Indeed, Allah is to you ever Merciful [Qur`an 4: 29].
Thabit Ibn Al-Dahak narrated that the Prophet [peace and blessings be upon him] said, “Whosoever kills himself with anything in this world will be tortured with it on the Day of Judgment.”
Definition of suicide
It is the act of killing oneself [intentionally].
The ruling on suicide
Suicide is prohibited in Islamic law according to evidence from the Qur`an, Sunna, and the consensus of Muslim scholars. A person who commits suicide commits a major sin, though this does not take him outside of Islam.
Washing, shrouding, and praying over a person who commits suicide
It is considered a fard kifaya [communal duty] upon Muslims to wash and shroud a person who commits suicide as well as to bury him in a Muslim cemetery. This is because he is a Muslim and is subject to the general rulings that apply to deceased Muslims. Shams Al-Din Al-Ramly cited in Nihayat al-Muhtaj that there is a unanimous agreement that washing, shrouding, and praying over a deceased and burying him are all considered fard kifaya. This is based on the command found in authentic transmissions pertaining to those who die either due to suicide or to other reasons.
Means of suicide
Active suicide: This means taking active steps to carry out a suicide. Examples include [among others], using a sword, spear, rifle, poison to kill oneself, jumping from great heights, throwing oneself in fire, and drowning.
Passive suicide: This means refraining from making an effort to stay alive. Examples include abstaining from food and drink, neglecting a treatable wound, staying motionless in water or fire, not trying to escape from an animal when one has the capacity to do so.
The ruling on committing suicide to avoid evil
It is impermissible to commit suicide to avoid evils such as rape and torture for instance. It is impermissible for a girl to commit suicide for fear of rape; she must defend herself against her attacker even if this means killing him. If she is killed in the process, she is considered a martyr because she died to defend her honor. The same applies to those who face humiliation and torture. They should resist their assailants and it is impermissible for them to commit suicide under the pretext that it is more honorable to kill themselves than to accept captivity and torture.
A Muslim is obligated to exercise patience at times of affliction and fight injustice to the best of his ability. He is not commanded to commit suicide to escape afflictions.
Allah the Almighty knows best.
Included in the Sahih of Bukhari and the Sahih of Muslim.