"Blue balls" is actually a term that describes a congestion of blood in the scrotum and prostate region. This congestion is often accompanied by pain, discomfort or cramping.
The main cause of this phenomenon is the prolonged sexual stimulation or arousal condition in which the penis is erect, but without orgasm or ejaculation to occur.
During arousal, the sympathetic nervous system is off and there is an increase of the amount of blood that reaches the scrotum, testicles and prostate region. As this happens, the muscles in that region shrinks and this greater quantity into that area than leaving the area. The purpose of this elevated amounts in this area is to maintain erection during intercourse.
For not reach orgasm or ejaculation, the blood becomes more oxygen-poor, but not leave the area. This is because in some cases it produces a bluish scrotum, hence the name of Blue Balls. (the blood enters first in the area is red and the more stagnant due to oxygenation more, losing oxygen and turns blue)
During the process vasoconstriction, testicles increase their size by 25-50%.
The fastest way to get rid of pain caused either by masturbation or ejaculation is through sexual intercourse. Ejaculation activates the sympathetic nervous system which helps dissipate blood in that area. Even without ejaculation, the symptoms disappear over time, but the pain and discomfort at first not negligible. Usually disappears after one hour.
Another way to get rid of pain is either a cold shower or immersing that area or scrotum in cold water, which increases blood circulation in the body and this in that area.
Those who suffer from priapism may suffer from an extreme form of this phenomenon and requires medical treatment.
Interestingly, women can suffer from this phenomenon. Women's genitals are also irrigated with blood in increased amounts during arousal and intercourse which causes congestion. If you do not reach orgasm may feel pelvic pressure and sometimes pain.