Masturbation is not a sin as long as it's consensual.
But on a more serious note there is no reference anywhere in the Bible that explicitly says masturbation is a sin. Some Christians point to the story of Onan in Genesis 38:9, 10); however, upon analysis this story is not about masturbation at all. Here is what the Bible says:
“And Er, Judah's firstborn, was wicked in the sight of the Lord; and the Lord slew him. And Judah said unto Onan, Go in unto thy brother's wife, and marry her, and raise up seed to thy brother. And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother's wife, that he spilled it on the ground, lest that he should give seed to his brother. And the thing which he did displeased the Lord: wherefore he slew him also” (Genesis 38:7-10, KJV).
There are some Christians who interpret these verses as portraying masturbation as sinful; however, other Christians believe he was killed solely because he refused to impregnate his dead brothers wife, not because his sperm was “wasted.” I side with the latter group, and here is a good explanation why I do::
“Why did God kill Onan for spilling his seed on the ground? The reason God did this is not because Onan wasted his seed on the ground, but because Onan refused to perform his familial duties of producing offspring for his brother's. This was a great offense at the time. Now, we must realize that the culture was very different than ours is today. In that culture, when a man died and left no children, the next of kin was sometimes obligated to "go in to" the wife and produce children. These children were then considered to be the descendents of the original late husband and would be raised as such. This way, the offspring would be able to take care of the mother, provide more people for the community, and thereby raise their own children, continuing the name of that family. Onan knew this and refused to take part in furthering the honor and name of the brother's wife and thereby also risking provision for her in the future. To this, God was very displeased and took Onan's life.”
http://carm.org/bible-difficulties/genesis-deuteronomy/why-did-god-kill-man-spilling-his-seed-ground
But there is an even more practical reason for rejecting the "wasted seed" theory. Assuming that Onan was a typical male, his body produced about 21,000 sperm cells each minute of every day. Further even after ejaculating, he still had enough seminal fluid for another 3-4 ejaculations and seminal fluid is replaced every 1-3 days. The truth is that every minute of his life Onan had more seed than he could ever use in his lifetime. I'm sure that God knows all of this, so the “seed wasting” hypothesis fails. Besides, males who are celibate also waste their seed and, unlike men who occasionally masturbate celibate men waste ALL their seed.
There is another Biblical reference used by some Christians that does not deal directly with masturbation; however it states that lusting after a woman is the same as committing adultery. The theory is that if you think about a woman while you are masturbating you are lusting after her and thus committing adultery. Here is what the bible says:
“Ye have heard that it was said by them of old time, Thou shalt not commit adultery: But I say unto you, That whosoever looketh on a woman to lust after her hath committed adultery with her already in his heart. And if thy right eye offend thee, pluck it out, and cast it from thee: for it is profitable for thee that one of thy members should perish, and not that thy whole body should be cast into hell. And if thy right hand offend thee, cut it off, and cast it from thee: for it is profitable for thee that one of thy members should perish, and not that thy whole body should be cast into hell” (Matthew 5:27-30, KJV).
Now I know there are various ways to define “lust for” but at a minimum it means to have an extreme and continuous desire for something such as having sex with someone. Now I cannot speak for all the masturbaters in the world, but I have never pursued all the woman I fantasized about. I didn't want to have sex with them; I just wanted to imagine having sex with them and there is a hell of a difference. I have been married for most of my life, have fantasized often during my marriages (both while masturbating and during intercourse) but I never cheated or wanted to. Further, outside the act of masturbating, I never gave a thought to any of the women I fantasized about. Did I lust after them? Hell no! Certainly not by any definition of “lust for” that I am willing to accept.
But that is just my own humble opinion (OK, I lied about the humble part).