How the Penis Works: Erection and Ejaculation

Medically Reviewed by Zilpah Sheikh, MD on May 17, 2024
8 min read

The penis is a male sexual organ.

The shaft is the longest part of it. The head or glans is at the end of the shaft. The opening at the tip of the head, where urine and semen come out, is called the meatus.

Inside, two cylinder-shaped chambers called the corpora cavernosa (singular: corpus cavernosum) run the length of the penis. They have a maze of blood vessels, tissue, and open pockets.

The urethra, the tube that urine and semen flow through, runs along the underside of them, in the spongy tissue of the corpus spongiosum.

Two main arteries (one in each of the corpora cavernosa) and several veins move blood in and out. Nerves relay messages to and from other parts of your body.


An erection occurs when your penis fills with blood, causing it to expand and become firm. You might have an erection if you feel sexually aroused, though sometimes they just happen.

An erection starts in your brain. Something you saw, felt, smelled, heard, or thought makes your nerves send chemical messages to the blood vessels in your penis. The arteries relax and open up to let more blood flow in; at the same time, the veins close up. Once blood is in the penis, pressure traps it within the corpora cavernosa. Your penis expands and holds the erection.

When the inflow of blood stops and the veins open, your penis becomes soft.

How to stop an erection

The most obvious way to stop an erection is to ejaculate, or release semen, which causes the penis to become soft. If that’s not an option or desirable, the old advice to take a cold shower may do the job. However, simply being patient and waiting a few minutes usually works, too. It may help to distract yourself by thinking about something other than sex, like that report you have to write for work or what to have for dinner. 

If you have an erection that doesn't go away on its own, see a doctor as soon as you can. Known as priapism, this is a potentially serious condition that needs medical treatment. 

Erection problems

Sometimes problems can occur with the parts that your body uses to produce an erection. Examples include: 

Erectile dysfunction. Also known as impotence, erectile dysfunction (ED) is the inability to have or maintain an erection adequate for sex. If you have a penis, you are bound to experience ED at one time or another, which is not a big cause for worry. However, ED can become a persistent problem and interfere with relationships. Erectile dysfunction can be caused by physical conditions such as heart disease or diabetes. Or it may be brought on by stress, anxiety, and other psychological problems. Sometimes, both physical and psychological factors may interfere with your ability to get and keep an erection. There are several effective treatment options for ED. 

Priapism. You might think of priapism as the opposite of ED, since it occurs when you have an erection that won’t go away. Priapism happens when blood that flows into the penis to create an erection gets trapped and won’t drain out. You may develop priapism during sex, but it can also be caused by some drugs. Priapism can be painful, damage tissues, and even disfigure your penis. If you have an erection that lasts longer than 4 hours, go to an emergency room.

Peyronie’s disease. This condition, also known as penile curvature, causes the penis to bend or curve. It can occur if scar tissue forms in the penis, which pulls on tissues, causing the shaft to bend. Peyronie’s disease can make erections painful and prevent you from having sex. Oral and injected medicines can help treat Peyronie’s disease, though surgery may be necessary. In some cases, Peyronie’s disease goes away on its own. 

When you're aroused, tubes called the vasa deferentia (singular: vas deferens) squeeze sperm from the testes toward the back of the urethra. The seminal vesicles also release fluid there.

The urethra senses the sperm and fluid mixture. Then, at the height of sexual excitement, it sends signals to your spinal cord, which in turn sends signals to the muscles at the base of your penis. These contract powerfully and quickly, every 0.8 seconds. This forces the semen out of the penis as you climax.

How much sperm is in ejaculation?

Sperm is made in your testicles. These male reproductive cells unite with female reproductive cells, or eggs, to form embryos, which can become babies. Scientists estimate that there can be up to 300,000,000 sperm cells in a single ejaculation. 

Why does ejaculation feel good?

You can thank evolution for the pleasant sensation you get from ejaculation. A man or person assigned male at birth (AMAB) must ejaculate in order to transfer sperm to a female partner for the purpose of reproduction; that is, having a baby. When you ejaculate, you have an orgasm, which causes your brain to release several different chemicals that leave you feeling great -- relaxed and at peace. Orgasms act like a reward for ejaculating, which makes you want to do it again. Since humans need to keep having sex for the species to survive, evolution ensured that ejaculation feels good. 

Premature ejaculation

Premature ejaculation (PE) happens when you ejaculate (or release semen) sooner than you intended during sex. It’s a common problem -- roughly 1 in 3 men and people AMAB experience it at one time or another. PE can be caused by psychological problems such as anxiety or lack of confidence. In some cases it may be related to low levels of certain brain chemicals. Different treatments are available for PE, including psychological counseling, sex therapy, and medication. 

Delayed ejaculation (also called difficulty ejaculating)

This condition causes you to take a long time to ejaculate. In some cases, you may not be able to ejaculate at all. Delayed ejaculation can be an occasional problem or it may happen whenever you have sex. Some people have delayed ejaculation when they have sex with a partner, but they’re able to ejaculate during masturbation. 

There are many potential causes of delayed ejaculation. Psychological issues such as depression and anxiety may interfere with your ability to ejaculate. Some medicines can be a problem, too. And certain diseases, medical procedures, injuries, and birth defects can also prevent normal ejaculation. If you’re bothered by delayed ejaculation, talk to your doctor.  

In a 2023 study, researchers asked men with difficulty ejaculating what they felt caused them to experience the problem. Some reasons they gave included:

  • Anxiety or stress
  • Not enough sexual stimulation
  • Couldn’t get sexually aroused
  • Medical problems
  • Relationship problems

Painful ejaculation

Ejaculation should feel pleasant, but some medical conditions and treatments can make it painful. With painful ejaculation, you typically feel discomfort in the penis, but you may also notice it in the testes, rectum, or the lower abdomen. The pain can be mild or unbearable and may be gone in a few seconds or last for several days. 

Painful ejaculation has many potential sources. Conditions such as an enlarged prostate and prostatitis can make ejaculation hurt, as can several lesser-known diseases. Surgery to treat prostate cancer can damage nerves and other tissues in a way that makes ejaculating painful. Some medications have the same effect. Treating an underlying cause of painful ejaculation or switching your medications may help ease this unpleasant problem. 


If you get an erection but have not ejaculated, your penis will likely release a small amount of fluid known as pre-ejaculate (or precum). Two small glands near the urethra -- the tube that carries pee and semen out of the penis – make pre-ejaculate. The role of this fluid is to reduce acidity in the urethra from urine so sperm are protected. Pre-ejaculate doesn’t contain sperm, but if there are any sperm cells lingering in the urethra, it can carry them. Because of this, it’s possible, though unlikely, that pre-ejaculate can make a female sex partner pregnant. 

Nocturnal emission

If you ejaculate during a dream, that’s a nocturnal emission, which is also known as a wet dream. Nocturnal emissions are completely normal, and most men and people who are AMAB have had one by age 21.

Ejaculation blockage

In order to ejaculate, semen has to travel through structures called the ejaculatory ducts. These ducts deliver semen to the urethra, the tube that allows this fluid (and urine) to pass out of the body through the tip of the penis. A condition known as an ejaculatory duct obstruction (EDO) can block the ducts, which can produce several symptoms:

  • Low output of ejaculate and sperm
  • Pain during or after sex
  • Prostate pain
  • Bloody semen and urine

And, particularly worrisome for would-be parents, EDO can make you infertile. There are many potential causes of EDOs, including scar tissue, stones, cysts, and conditions such as prostatitis. What’s more, you might simply be born with an EDO. Effective treatments are available for ejaculation blockage. 

Having an erection requires a complex series of events to occur, beginning with nerve signals from the brain that trigger blood to fill vessels in the penis and make it expand. 

Medical conditions and even some treatments can disturb the steps involved in forming erections, resulting in problems such as erectile dysfunction and priapism. 

Ejaculation is a pleasurable and important part of sex, but it can happen too fast or too slowly and be painful for some. 

Your doctor can offer solutions to most problems with erections and ejaculation. 

How long can the average person stay erect?

There is great variety in how long an erection can last, ranging from minutes to a few hours. However, during sex, the average man and person AMAB reaches orgasm in 5 to 7 minutes. After ejaculating, an erection goes away. 

What is the simple trick to cure ED?

There are no simple tricks for curing ED. If you are consistently unable to get or maintain an erection, talk to your doctor. They'll attempt to diagnose what’s causing the problem and recommend a solution that’s right for you.