Sin is often the result of lust or wrong selfish desire. This fact forms the primary basis of answering this question. Jesus tells us in Matthew 5:28 Matthew 5:28But I say to you, That whoever looks on a woman to lust after her has committed adultery with her already in his heart.
American King James Version×that “whoever looks at a woman to lust for her has already committed adultery with her in his heart.” Sexual lusting in the mind is the primary reason or trigger for masturbation and is sin—whether from erotic imagery, viewing pornography, or lusting after a person who is not one’s spouse. A Christian must therefore learn to control his thoughts (2 Corinthians 10:5 2 Corinthians 10:5Casting down imaginations, and every high thing that exalts itself against the knowledge of God, and bringing into captivity every thought to the obedience of Christ;
American King James Version×).
As the apostle James wrote: “But each one is tempted when he is carried away and enticed by his own lust. Then when lust has conceived, it gives birth to sin” (James 1:14-15 James 1:14-15  But every man is tempted, when he is drawn away of his own lust, and enticed.
 Then when lust has conceived, it brings forth sin: and sin, when it is finished, brings forth death.
American King James Version×, New American Standard Bible).
The Bible specifically forbids adultery, fornication, homosexual sex, incest, bestiality and lust but does not mention masturbation or self-stimulation. Masturbation as part of sexual relations between married partners would not be classified as sin. But masturbation outside of marital relations commonly is sinful, being often accompanied by wrong lustful thoughts, such as when viewing pornography.
The use of pornography (including so called “soft porn”) is definitely a sin, as it violates Christ’s teaching in Matthew 5:28 Matthew 5:28But I say to you, That whoever looks on a woman to lust after her has committed adultery with her already in his heart.
American King James Version×. Looking lustfully at risqué entertainment and immoral fantasizing are all clearly sinful. Addictions to porn and masturbation will reinforce each other. When a person stops viewing or thinking about anything wrongly erotic, there won’t be so much improper sexual arousal with urges to masturbate.
The Bible does not teach asceticism, such as the pagan Gnostic teaching that all physical things are evil, including the human body. God designed human beings with sexuality—“male and female” (Genesis 1:27 Genesis 1:27So God created man in his own image, in the image of God created he him; male and female created he them.
American King James Version×; Matthew 19:4 Matthew 19:4And he answered and said to them, Have you not read, that he which made them at the beginning made them male and female,
American King James Version×)—for many reasons, but especially so they can marry, enjoy marital love, have children and enjoy many other blessings. Marriage is sacred and critically important to God. Therefore, one must not allow anything to hinder the success of his or her present marriage or a future marriage.
Lustful self-stimulation can easily become a habit that hurts a marital relationship and future sexual satisfaction with one’s spouse. A habit formed before marriage can be difficult to break even after getting married. Many marriages have been seriously hurt because one or both of the spouses had a secret habit of masturbation. (The United Church of God offers a valuable free study guide on love, sex and marriage—Marriage and Family: The Missing Dimension.)
Because sex is powerful, masturbation can also become an addiction. Any addiction is spiritually dangerous because it has become the master, and the addict has become the slave—and we must only be “slaves of God” (Romans 6:22 Romans 6:22But now being made free from sin, and become servants to God, you have your fruit to holiness, and the end everlasting life.
American King James Version×). Remember that it is easier to prevent a habit or addiction than to break an already-formed habit or addiction.
As Christians, we are to be “bringing every thought into captivity to the obedience of Christ” (2 Corinthians 10:5 2 Corinthians 10:5Casting down imaginations, and every high thing that exalts itself against the knowledge of God, and bringing into captivity every thought to the obedience of Christ;
American King James Version×). This of course requires His help. We must constantly be asking God to renew and strengthen us. The practical method for stopping unwanted thoughts is to replace them with good thoughts (Philippians 4:6-8 Philippians 4:6-8  Be careful for nothing; but in every thing by prayer and supplication with thanksgiving let your requests be made known to God.  And the peace of God, which passes all understanding, shall keep your hearts and minds through Christ Jesus.  Finally, brothers, whatever things are true, whatever things are honest, whatever things are just, whatever things are pure, whatever things are lovely, whatever things are of good report; if there be any virtue, and if there be any praise, think on these things.
American King James Version×). Strive with God’s help for spiritual growth in all areas of life and, as a result, you will become stronger in those areas where you have been the weakest.
Once God has called us to be His disciples, we are doubly responsible to Him for how we use our time, our minds and our bodies. We are called to bear “good fruit” and “much fruit” spiritually (Matthew 7:15-20 Matthew 7:15-20  Beware of false prophets, which come to you in sheep's clothing, but inwardly they are ravening wolves.
 You shall know them by their fruits. Do men gather grapes of thorns, or figs of thistles?
 Even so every good tree brings forth good fruit; but a corrupt tree brings forth evil fruit.
 A good tree cannot bring forth evil fruit, neither can a corrupt tree bring forth good fruit.
 Every tree that brings not forth good fruit is hewn down, and cast into the fire.
 Why by their fruits you shall know them.
American King James Version×; John 15:1-8 John 15:1-8  I am the true vine, and my Father is the farmer.  Every branch in me that bears not fruit he takes away: and every branch that bears fruit, he purges it, that it may bring forth more fruit.  Now you are clean through the word which I have spoken to you.  Abide in me, and I in you. As the branch cannot bear fruit of itself, except it abide in the vine; no more can you, except you abide in me.  I am the vine, you are the branches: He that stays in me, and I in him, the same brings forth much fruit: for without me you can do nothing.  If a man abide not in me, he is cast forth as a branch, and is withered; and men gather them, and cast them into the fire, and they are burned.  If you abide in me, and my words abide in you, you shall ask what you will, and it shall be done to you.  Herein is my Father glorified, that you bear much fruit; so shall you be my disciples.
American King James Version×). And part of the fruit of God’s Spirit is self-control (Galatians 5:22-23 Galatians 5:22-23  But the fruit of the Spirit is love, joy, peace, long-suffering, gentleness, goodness, faith,  Meekness, temperance: against such there is no law.
American King James Version×). Don’t allow anything habit-forming or lustful to interfere with these goals.
Make sure to pray to God and read His Word every day to discern His will in your life. In that way, you are regularly talking to God and listening as He speaks to you. We encourage you to read our free study guide Tools for Spiritual Growth. It thoroughly explains prayer, Bible study, fasting, meditation and three other “tools” that are essential for spiritual growth. We highly recommend it!