Leg cramps are caused by involuntary, sustained muscle contractions that happen when the nerves controlling your muscles become overly excitable. The specific trigger varies, from simple muscle fatigue and mineral shortages to medication side effects and nerve compression. Up to 33% of adults over 50 experience nighttime leg cramps regularly, making this one of the most common muscle complaints in middle and older age.
How a Cramp Actually Happens
Your muscles contract and relax based on a balance of signals from your nervous system. One set of nerve sensors (in your muscle fibers) sends “contract” signals, while another set (in your tendons) sends “relax” signals. A cramp occurs when that balance tips too far toward contraction. The nerve cells driving the muscle fire excessively, locking the muscle into a painful, sustained squeeze.
This is why stretching works as an immediate treatment. When you stretch a cramping muscle, you increase tension on the tendon, which activates those “relax” sensors and helps restore the normal balance of nerve signals. It’s also why cramps tend to strike muscles that are already in a shortened position, like your calf when your foot is pointed downward in bed. In that shortened state, the tendon is slack and the relaxation signals are naturally reduced.
Muscle Fatigue and Overuse
The best-supported explanation for exercise-related cramps is neuromuscular fatigue, not dehydration. A review in the British Journal of Sports Medicine found that the evidence behind the popular “dehydration and electrolyte loss” theory comes mostly from anecdotal observations and a handful of small case reports. Four prospective studies failed to support it. Meanwhile, research from human cramping models, athlete studies, and lab experiments increasingly points to fatigue-driven nerve dysfunction as the primary cause.
When a muscle is overworked or poorly conditioned for the activity you’re doing, the nerve signals that normally keep it in check start to malfunction. The result is an uncontrolled contraction. This explains why cramps during exercise tend to hit the specific muscles doing the most work, rather than affecting muscles throughout the body the way widespread dehydration would.
Mineral and Electrolyte Shortages
Low magnesium is one of the most well-documented mineral-related causes of muscle cramps. Normal blood magnesium sits between 1.46 and 2.68 mg/dL, and symptoms like muscle spasms, cramps, and involuntary twitching typically appear once levels drop below 1.2 mg/dL. About 60% of people with low magnesium also have low potassium, compounding the problem since potassium plays its own role in muscle and nerve function.
You don’t need to be severely deficient to notice an effect. Mild shortages can develop gradually from a diet low in leafy greens, nuts, and whole grains, or from conditions that increase mineral loss through urine. Heavy sweating over long periods, chronic alcohol use, and certain digestive disorders all increase your risk.
Medications That Trigger Cramps
Cholesterol-lowering statins are among the most commonly reported medication-related causes of leg cramps. Statins work by blocking an enzyme in the liver that produces cholesterol, but the same pathway also produces compounds your muscles need for energy production and cell maintenance. The resulting muscle effects range from cramping and soreness to fatigue and weakness. The underlying problem appears to involve impaired energy production within muscle cells, particularly in the mitochondria.
Diuretics (water pills) are another frequent culprit. By increasing urine output, they can deplete magnesium, potassium, and calcium, all of which your muscles depend on. If your cramps started or worsened after beginning a new medication, that timing is worth noting and discussing with whoever prescribed it.
Nighttime Cramps and Aging
Nocturnal leg cramps are especially common after age 50. They tend to hit the calves or the small muscles of the feet, often waking you from sleep. The exact reason they favor nighttime isn’t fully settled, but the position of your feet during sleep likely plays a role. When you lie flat or sleep on your stomach, your feet naturally point downward, shortening the calf muscle and reducing the tendon feedback that normally prevents involuntary contractions.
Aging also brings a gradual loss of motor neurons, the nerve cells that control muscle fibers. Fewer motor neurons means the remaining ones must work harder, which can make them more prone to misfiring. Add in the reduced activity levels, changes in blood flow, and increased medication use that often come with age, and the conditions for cramps become more favorable.
Pregnancy-Related Cramps
Leg cramps become noticeably more common in the second half of pregnancy, particularly at night. Pregnancy naturally lowers blood magnesium levels compared to the non-pregnant state, and that relative shortage is thought to be a key contributor. The added weight, changes in circulation, and increased mineral demands of a growing baby all add strain.
Sleep disruption from these cramps can create a cycle: poor sleep increases fatigue, and fatigue itself can make muscles more cramp-prone. Supplemental magnesium during pregnancy has been studied as a potential remedy, though results have been mixed.
Nerve Compression in the Spine
Narrowing of the spinal canal in the lower back, called lumbar spinal stenosis, can compress the nerve roots that control leg muscles. Several studies have identified this nerve compression as an underlying cause of nocturnal leg cramps. The mechanism falls into the category of lower motor neuron disorders, meaning the problem originates where the nerves exit the spine rather than in the brain.
If your leg cramps come with other symptoms like numbness, tingling, or pain that worsens when you stand or walk and improves when you sit or lean forward, spinal narrowing could be involved. These cramps tend to be more persistent and less responsive to simple remedies like stretching or mineral supplements.
Kidney Disease and Dialysis
People with chronic kidney disease, especially those on dialysis, experience leg cramps at high rates. During dialysis, fluid is removed from the bloodstream to compensate for the kidneys’ inability to filter it. When too much fluid is removed too quickly, the blood becomes more alkaline. This shift causes calcium in the blood to bind to proteins instead of staying freely available, and the resulting calcium shortage triggers muscle cells to contract uncontrollably.
There’s a second layer to this problem. Dialysis patients often become deficient in carnitine, a compound that helps muscle cells produce energy. Without enough carnitine, muscles can’t generate the energy needed to pump calcium back into storage after a contraction, so the muscle stays locked in its contracted state. This is why cramps during dialysis tend to occur in the second half of a session, after significant fluid has already been removed.
Identifying Your Likely Cause
Most occasional leg cramps in otherwise healthy people trace back to muscle fatigue, prolonged sitting or standing, or sleeping in a position that shortens the calf. These cramps are annoying but harmless, and stretching the affected muscle usually resolves them within seconds to minutes.
Cramps that happen frequently, severely disrupt your sleep, or come alongside other symptoms like muscle weakness, numbness, or swelling point toward something more specific. The pattern matters: cramps that started with a new medication, cramps that cluster during pregnancy, cramps paired with back pain, or cramps in someone with kidney disease each suggest a different underlying mechanism and a different path to relief.

