An erection is the hardening of the penis when it becomes engorged with blood. Although they can appear spontaneously, they are usually a physiological response to mental or physical sexual stimulation.
The penis contains two tubular structures - the corpora cavernosa. They are usually empty of blood. However, when there is a complex interaction of hormones, the parasympathetic nervous system, and various physical reactions, blood from the veins that run through the penis become trapped in the corpora.
Due to its relationship to the parasympathetic nervous system, an erection cannot be consciously controlled.
Several physical and endocrine conditions can result in an inability to achieve an erection, resulting in erectile dysfunction or impotence. In most cases, the occurrence of orgasm will result in the loss of an erection.
Priapism is a condition where an erection lasts for a lengthy period of time, no matter what the physical response. Priapism is a medical emergency and is the result of either a serious underlying condition or a side effect of the medication used to treat erectile dysfunction.