Leg cramps are sudden, involuntary muscle contractions that can strike during exercise, in the middle of the night, or seemingly out of nowhere. They happen when motor neurons fire excessively, causing a muscle to lock into a painful contraction that can last seconds to several minutes. Most leg cramps are harmless, but they can also signal an underlying health issue worth paying attention to.
What Happens Inside the Muscle
A cramp starts with your nerves, not your muscle. Motor neurons become hyperexcitable and fire repeatedly, forcing the muscle into a sustained contraction it can’t release. Normally, your body keeps this in check through a balance between two signals: excitatory impulses from sensors in the muscle fibers (which tell a muscle to contract) and inhibitory impulses from sensors in the tendons (which tell it to relax). When that balance tips too far toward excitation, a cramp occurs.
Several things can tip that balance. Electrolyte shifts, metabolic stress, nerve injury, and simple fatigue all make motor neurons more likely to fire on their own. In some cases, the muscle’s energy supply runs low, which impairs its ability to relax even after the nerve signal stops. This is why cramps often feel like the muscle is “stuck” and why they can leave behind soreness even after they release.
Exercise and Muscle Fatigue
If you’ve ever gotten a cramp mid-run or during a long hike, the leading explanation is neuromuscular fatigue. As a muscle tires, excitatory signals from muscle spindles ramp up while inhibitory signals from tendon sensors drop off. The result is a runaway loop of nerve firing at the spinal level that overwhelms your muscle’s ability to relax. Cramps triggered this way tend to hit muscles that are already contracting in a shortened position, which is why calf cramps are so common during activities that involve repeated pushing off the foot.
For years, dehydration and electrolyte loss were considered the primary culprits behind exercise cramps. But research on ultra-distance runners has complicated that story. In one study, runners who cramped during a race did not show clinically meaningful differences in hydration status or electrolyte levels compared to those who didn’t cramp. Sodium was slightly lower in the cramp group, and magnesium was actually slightly higher. This doesn’t mean hydration is irrelevant, but it does suggest that fatigue and nerve dysfunction play a bigger role than fluid loss alone during prolonged exercise.
Nocturnal Leg Cramps
Nighttime cramps, typically in the calf or foot, are among the most common. They often wake you from sleep with a sharp, seizing pain that can last from a few seconds to several minutes. The exact trigger is harder to pin down than exercise cramps because you’re not doing anything strenuous at the time.
Several factors contribute. Sitting for long stretches during the day, standing on hard surfaces like concrete, and poor posture can all set the stage. A sedentary lifestyle reduces lower-limb muscle activity and allows fluid to pool in the tissues, which can put pressure on nerves and blood vessels. Then, when you lie down and shift position in your sleep, a slight movement can trigger a motor neuron to fire excessively in an already-irritable muscle. Involuntary nerve discharges during sleep appear to be a direct mechanism.
Why Cramps Get More Common With Age
Nearly half of adults over 60 experience cramps, based on a primary care study that found an adjusted prevalence of 46% in that age group. Prevalence peaked at about 52% in people aged 65 to 74. Both men and women are affected at similar rates.
Age increases cramp risk for several overlapping reasons. Tendons naturally shorten over time, which means muscles spend more time in slightly contracted positions, making them easier to trigger. Older adults also tend to lose muscle mass, so remaining fibers bear more load and fatigue faster. Circulation problems become more common with age too. The same study found significant associations between cramps and both venous insufficiency and peripheral artery disease, conditions that reduce blood flow to the legs and the nerves that supply them.
Medical Conditions That Cause Cramps
While most cramps are benign, some point to a medical issue that deserves attention.
- Reduced blood flow. Narrowing of the arteries that supply the legs can cause cramping pain during exercise that stops shortly after you rest. If your legs cramp consistently with walking and feel better when you stop, this pattern is worth bringing up with a provider.
- Nerve compression. Pressure on spinal nerves can produce cramping pain in the legs that worsens with walking. People with this issue often notice relief when leaning forward, such as when pushing a shopping cart.
- Peripheral neuropathy. Nerve damage from diabetes or other causes can trigger cramps along with tingling, numbness, or pain.
- Kidney disease. Kidney failure disrupts the body’s electrolyte balance and waste removal, both of which can increase nerve and muscle excitability.
- Liver cirrhosis. Cirrhosis reduces energy supply to muscles and can impair blood flow to nerves, contributing to frequent cramping.
Mineral Deficiencies
Low levels of potassium, calcium, or magnesium can destabilize muscle membranes and make cramps more likely. These minerals help regulate the electrical signals that control muscle contraction and relaxation. When levels drop, nerve and muscle cells become more excitable and prone to firing spontaneously.
One common and overlooked cause of mineral depletion is medication. Diuretics prescribed for high blood pressure increase urination, which drains potassium, magnesium, and calcium from the body. If you started a blood pressure medication and noticed more frequent cramps afterward, the connection is likely real.
Medications That Trigger Cramps
Beyond diuretics, several drug classes list muscle cramps as a side effect. These include certain blood pressure medications (both angiotensin receptor blockers and some beta-blockers), cholesterol-lowering statins, asthma inhalers (bronchodilators), birth control pills, and some chemotherapy drugs. If cramps started or worsened after beginning a new medication, that’s useful information for your prescriber.
Pregnancy and Leg Cramps
Leg cramps are especially common during the third trimester of pregnancy. Hormonal and physiological changes cause the body to retain more fluid, and about 35% of women in late pregnancy develop noticeable leg swelling, which is a significant predictor of cramps. The extra fluid puts pressure on nerves and blood vessels, reducing blood return from the lower legs. Added body weight, changes in posture, and prolonged standing (particularly during housework) compound the effect by increasing fatigue and swelling in the lower limbs.
How to Stop a Cramp in the Moment
Stretching is the most effective immediate treatment, and it works for a specific physiological reason. Stretching increases tension on the tendon, which activates the inhibitory sensors that were failing to fire. This helps shut down the overexcited motor neuron and lets the muscle relax.
For a calf cramp, keep your leg straight and pull the top of your foot toward your shin. You can also stand and press your weight down through the cramped leg. For a cramp in the front of your thigh, stand on the opposite leg, bend the knee of the cramped side, and pull that foot up toward your buttock (holding a chair for balance). Gentle massage during and after the stretch can help ease residual tightness.
Reducing Cramp Frequency Over Time
Evidence for long-term prevention strategies is more limited than you might expect. Passive stretching, massage, and light exercise before bed are commonly recommended, but studies have not yet produced strong proof that these reliably prevent nighttime cramps. That said, they carry no risk and many people report benefit.
What does have clearer support is addressing the underlying contributors. Staying physically active throughout the day helps maintain muscle conditioning and prevents fluid from pooling in the legs. If you sit for long periods, regular movement breaks matter. Ensuring adequate intake of potassium (found in bananas, potatoes, and leafy greens), magnesium (nuts, seeds, whole grains), and calcium supports normal muscle function. Drinking enough water throughout the day is sensible general practice, even if dehydration alone isn’t the primary cramp trigger research once assumed it was. Compression stockings are being studied as a potential intervention for older adults prone to nighttime cramps, though results are still pending.

