An erection happens when blood fills two sponge-like chambers inside the penis and gets trapped there under pressure. The process involves your brain, nerves, blood vessels, hormones, and a specific chain of chemical signals that all have to work together. It looks simple from the outside, but the mechanics underneath are surprisingly precise.
How the Signal Starts
Erections begin in one of two ways, and they use different nerve pathways. A psychogenic erection starts in the brain, triggered by something you see, hear, imagine, or remember. Those signals travel down the spinal cord through nerves at the mid-to-lower back level (T11 through L2). A reflexogenic erection starts from direct physical touch to the genitals, which sends signals through a lower set of nerves near the base of the spine (S2 through S4). Both pathways can work independently. That’s why erections can happen from fantasy alone, from touch alone, or from both at once.
In healthy men, these two systems overlap and reinforce each other. During sex, visual arousal and physical stimulation are usually both contributing. But in certain spinal cord injuries, one pathway can be knocked out while the other still functions, which tells us they really are separate circuits.
The Chemical Chain Reaction
Once arousal signals reach the penis, nerve endings and blood vessel walls release a small gas molecule called nitric oxide. This is the key chemical trigger. Nitric oxide activates an enzyme that produces a second messenger molecule called cGMP, which acts like an “open” switch for the smooth muscle cells lining the blood vessels and spongy tissue inside the penis.
When cGMP levels rise, those smooth muscle cells relax. Relaxed muscle means the arteries widen and the spongy chambers expand, allowing a rapid surge of blood into the penis. Without nitric oxide kicking off this cascade, the smooth muscle stays contracted and blood flow stays at its normal, low baseline. This is why conditions that damage blood vessel linings or reduce nitric oxide production (like diabetes, high blood pressure, or heavy smoking) directly impair erections.
How Blood Gets Trapped
Getting blood into the penis is only half the job. The other half is keeping it there, and the anatomy handles this with an elegant trapping mechanism.
The two main erectile chambers (the corpora cavernosa) are wrapped in a tough, fibrous sheath called the tunica albuginea. Tiny veins that drain blood out of the penis run between the expanding spongy tissue and this outer sheath. As the chambers fill with blood and swell, they press those small drainage veins flat against the tunica, like stepping on a garden hose. This compression cuts off the outflow, trapping blood inside under pressure. The result is rigidity.
The whole process, from arousal signal to full erection, typically takes seconds to a few minutes depending on the level of stimulation. The trapped blood stays under pressure as long as the smooth muscle remains relaxed and the arousal signals keep coming.
What Makes It Go Away
Your body has a built-in off switch: an enzyme called PDE5 that breaks down cGMP. As cGMP gets broken down, the smooth muscle in the erectile chambers gradually contracts again. The spongy tissue shrinks, the compression on the drainage veins releases, and blood flows back out into normal circulation. The penis returns to its soft state.
This is exactly why medications like sildenafil (Viagra) work. They block PDE5 from doing its job, so cGMP sticks around longer and the erection is easier to maintain. They don’t create arousal out of nothing. They just slow down the cleanup process once the chemical cascade has already started. Without that initial nitric oxide release from genuine arousal, the drugs have nothing to amplify.
When PDE5 doesn’t work properly, erections can persist dangerously long. Research in mice lacking certain enzymes showed that without normal PDE5 activity, cGMP levels stayed elevated after stimulation stopped, causing prolonged, uncontrolled erections. This is essentially what happens in priapism, a medical emergency where blood stays trapped for hours.
The Role of Testosterone
Testosterone doesn’t directly cause erections, but it sets the stage for them. It maintains sex drive, keeps nerve signaling responsive, and supports the health of erectile tissue. Think of it as the background condition that lets the whole system run properly.
The American Urological Association defines low testosterone as a total level below 300 ng/dL, measured on at least two separate morning blood draws. Below that threshold, men commonly report weaker erections, reduced desire, or both. That said, there’s no clean cutoff where erections suddenly fail. Some men experience problems above 300, and others function fine somewhat below it. The relationship is more of a sliding scale than a switch.
Low testosterone is recognized as a contributing factor to erectile difficulties, but it’s rarely the only cause. Most erection problems in men over 40 involve blood vessel health, nerve function, or psychological factors alongside whatever hormonal contribution exists.
Nighttime Erections and What They Tell You
Healthy men get erections during sleep without any sexual stimulation. These happen during REM sleep cycles and occur three to five times per night, each lasting up to 20 or 30 minutes. They’re not driven by erotic dreams. They appear to be a maintenance function, keeping erectile tissue oxygenated and healthy.
Nighttime erections are also a useful diagnostic clue. If you’re having trouble getting hard during sex but still wake up with morning erections (which are just the tail end of the last sleep cycle’s erection), that strongly suggests the physical plumbing works fine and the issue is more likely psychological. If nighttime and morning erections have disappeared too, that points more toward a physical cause like blood vessel disease, nerve damage, or hormonal deficiency.
Physical vs. Psychological Causes of Problems
When erections stop working reliably, the pattern of how they fail often reveals why. Problems with a physical origin tend to come on gradually, getting slightly worse over months or years. Erections become less firm rather than disappearing overnight. Desire and ejaculation usually remain normal, and there are often medical risk factors in the picture: diabetes, heart disease, high blood pressure, smoking, heavy alcohol use, or certain medications.
Psychological causes tend to look different. The onset is usually sudden, often linked to a new relationship, a breakup, stress, or a major life event. Erections during sleep and with self-stimulation are typically still normal or even better than usual, but they collapse during partnered sex. Difficulty with ejaculation (either too fast or not at all) is more common with psychological causes as well.
In practice, many men have a mix of both. A mild physical decline in erection quality creates anxiety, and the anxiety makes the problem worse. The brain is, after all, where psychogenic erections originate. Performance worry can suppress the very nerve signals that start the whole cascade, creating a feedback loop that feels purely physical but has a significant mental component.

