An erection happens when blood rapidly fills two sponge-like chambers inside the penis and then gets trapped there. The process involves your brain, nerves, blood vessels, and hormones all working together in a precise sequence. It takes only seconds, but the biology behind it is surprisingly complex.
The Internal Structure That Makes It Possible
The penis contains two cylindrical chambers called the corpora cavernosa that run side by side along its length. These chambers are made of connective tissue, smooth muscle, and a network of tiny open spaces (think of them like a sponge). Internal pillars act as struts, keeping the spongy tissue structurally sound so it can hold its shape under pressure.
Wrapping around each chamber is a tough, fibrous sheath about 2 millimeters thick called the tunica albuginea. It has two layers of collagen and elastic fibers arranged in different directions, giving it both strength and flexibility. This sheath is the key to rigidity. It’s strong enough to contain high-pressure blood, but flexible enough to allow expansion. When an erection fails, it’s often because something has gone wrong with either the blood flow into these chambers or the sheath’s ability to keep it there.
Two Ways an Erection Starts
Your body can trigger an erection through two distinct pathways, each using different sets of nerves in your spinal cord.
A psychogenic erection starts in the brain. Something you see, hear, imagine, or remember triggers arousal, and signals travel down through spinal nerves in your mid-to-lower back (around the T11 to L2 vertebrae). This is why a fantasy or a visual cue can produce an erection without any physical contact.
A reflexogenic erection starts from direct physical touch to the genitals. Sensory nerves send signals to a reflex center lower in the spinal cord (around the S2 to S4 vertebrae), which fires back a response without needing input from the brain at all. This is why erections can happen during a medical exam or in situations where you’re not mentally aroused. It also explains something important about spinal cord injuries: men with damage high on the spinal cord may lose the ability to get erections from mental arousal but can still respond to physical touch, because the reflex arc lower in the spine remains intact.
The Chemical Chain Reaction
Regardless of which pathway triggers the process, the same chemical sequence unfolds inside the penis. Nerve endings and blood vessel walls release a gas called nitric oxide. This single molecule is the master switch for the entire erection.
Nitric oxide activates an enzyme in the smooth muscle cells lining those spongy chambers. That enzyme produces a signaling molecule (cyclic GMP) that tells the smooth muscle to relax. As the muscle relaxes, the tiny coiled arteries feeding the chambers open wide. Blood rushes in, and the spongy spaces expand like a balloon filling with water. The increased blood flow itself stimulates the blood vessel lining to release even more nitric oxide, creating a reinforcing loop that sustains the process.
This is exactly where medications for erectile dysfunction work. They block the enzyme that breaks down cyclic GMP, keeping the “relax” signal active for longer. They don’t create desire or arousal on their own. They amplify the chemical cascade that’s already been triggered.
How Blood Gets Trapped
Filling the chambers with blood is only half the equation. The penis stays hard because of a built-in trapping mechanism. As the spongy tissue expands with incoming blood, it presses the small veins that would normally drain blood out of the penis against the inner surface of that tough outer sheath. The veins get compressed flat, like stepping on a garden hose. Blood flows in freely through the arteries but can barely escape through the squeezed veins.
This is what transforms a soft organ into a rigid one. The corpora cavernosa become a pressurized hydraulic system, with the tunica albuginea acting as the containment wall. The pressure inside can reach levels comparable to your blood pressure. If the sheath is damaged, which is what happens during the rare injury known as a penile fracture, it’s a medical emergency because the pressurized system ruptures.
Testosterone’s Supporting Role
Testosterone doesn’t directly cause erections, but it keeps the machinery running. In animal studies, removing testosterone significantly reduced the number of nerve cells that produce nitric oxide in the brain’s arousal center. Without adequate testosterone, the brain produces less of the chemical that kicks off the entire cascade. This is one reason low testosterone is linked to erectile problems: not because the blood vessels or chambers stop working, but because the signaling system that initiates the process becomes sluggish.
Testosterone also influences sex drive at the brain level, which affects the psychogenic pathway. Men with very low testosterone often report reduced desire alongside reduced erectile function, and the two are connected through overlapping brain chemistry.
Erections During Sleep
Healthy men typically experience four to five erections per night during REM sleep, each lasting roughly 25 to 35 minutes. These happen automatically and aren’t tied to sexual dreams. They appear to be the body’s way of oxygenating and maintaining penile tissue. The morning erection many men notice is usually the last of these, coinciding with waking up during or just after a REM cycle.
Nocturnal erections are actually useful as a diagnostic signal. If a man has trouble getting erections while awake but still gets them during sleep, the physical plumbing is likely working fine, and the issue is more likely psychological, neurological, or related to performance anxiety. If nighttime erections are also absent, it points toward a blood flow or nerve problem.
Why Erections End
An erection reverses when the chemical signals wind down. Enzymes inside the smooth muscle cells break down cyclic GMP, which allows the muscle to contract again. The arteries narrow, blood flow decreases, and the spongy tissue shrinks. As it shrinks, the veins are no longer compressed, and blood drains out normally. The whole process can take a few minutes after arousal ends, or it can happen quickly in response to stress, cold, or a sudden shift in attention, because the sympathetic nervous system (your “fight or flight” wiring) actively counteracts the relaxation signals that maintain an erection.

