Leg cramps happen when a muscle suddenly contracts on its own and won’t relax. They most commonly strike the calf, though the thigh and foot are frequent targets too. Most cramps are harmless and pass within seconds to a few minutes, but they can be surprisingly painful, and recurring episodes usually point to an identifiable trigger you can address.
What Happens Inside the Muscle
A cramp isn’t just a tight muscle. It’s a burst of uncontrolled electrical activity that starts in your nervous system. Current evidence points to the spinal cord, not the muscle itself, as the source. Normally, two signals stay in balance: one from sensors in the muscle that tell it to contract, and another from sensors in the tendon that tell it to relax. When that balance tips, the nerve cells controlling the muscle fire rapidly and the muscle locks up.
This is why cramps tend to hit muscles that are already shortened or fatigued. A tired calf muscle, for example, sends abnormal signals back to the spinal cord, ramping up the “contract” signal while the “relax” signal from the tendon fades. The result is that sudden, involuntary tightening you feel.
Common Causes of Leg Cramps
Muscle Fatigue and Overuse
The single most supported explanation for exercise-related cramps is neuromuscular fatigue. When you push a muscle beyond what it’s conditioned to handle, whether through a longer run, a heavier workout, or even a full day on your feet, the nerve signaling described above becomes unstable. This is why cramps are more common toward the end of a race or during the final set of an exercise, not at the beginning. Training gradually and avoiding sudden jumps in intensity is the most effective way to reduce these cramps.
Electrolyte Imbalances
Your muscles rely on a precise balance of minerals to contract and relax properly. Calcium triggers contraction, magnesium enables relaxation, and potassium supports both processes at the cellular level. When any of these run low, the muscle’s ability to cycle smoothly between contraction and relaxation breaks down. Sodium matters too: heavy sweating or drinking large amounts of plain water can dilute sodium levels enough to trigger cramping. If your cramps tend to follow heavy sweating or periods of poor eating, an electrolyte gap is a likely culprit.
Nighttime Cramps
Nocturnal leg cramps are extremely common, and in most cases no specific cause is found. They likely result from a combination of fatigued muscles and nerve irritability that builds up over the day. The risk increases with age. Sleeping with your feet pointed downward (a natural position under blankets) keeps the calf in a shortened state, which may make it more vulnerable to spontaneous firing. Sleeping with a loose blanket or propping your feet at a neutral angle can help.
Medications
Several common medications list muscle cramps or pain as a side effect. Statins (cholesterol-lowering drugs) are the most well-known offender. In real-world use, roughly 15% to 20% of patients on statins report muscle-related symptoms, with women affected more often than men. Diuretics (water pills) can also trigger cramps by depleting potassium and sodium through increased urination. If your cramps started or worsened after beginning a new medication, that connection is worth raising with your prescriber.
Pregnancy
Leg cramps are a familiar complaint during pregnancy, particularly in the second and third trimesters. The exact mechanism isn’t fully understood, but the combination of extra body weight, changes in circulation, and shifting mineral demands on the body all likely contribute. Gentle calf stretches before bed and staying well hydrated are the most commonly recommended strategies.
When Cramps Signal Something Else
Poor Circulation
Not all leg pain that feels like a cramp is a true muscle cramp. Peripheral artery disease (PAD) causes cramping pain in the calves, thighs, or hips during walking or climbing stairs because narrowed arteries can’t deliver enough blood to meet the muscle’s demand. The key difference: PAD pain reliably starts with activity and stops with rest. It can range from mild to severe, and in advanced cases it can wake you from sleep or occur even when you’re lying down. If your leg pain follows this pattern, especially in just one leg, it warrants a medical evaluation.
Nerve Compression
Spinal stenosis, a narrowing of the spinal canal in the lower back, can produce cramping pain in one or both legs. The hallmark pattern is pain or cramping that worsens when you stand or walk for extended periods but improves when you sit down or lean forward, like resting on a shopping cart. This happens because leaning forward opens the spinal canal slightly and takes pressure off the compressed nerves. If your leg cramps consistently follow this positional pattern, the source may be your back rather than your legs.
How to Stop a Cramp in Progress
When a cramp hits, your goal is to lengthen the locked muscle. For a calf cramp, straighten your leg 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 thigh cramp in the back of the leg, the same standing technique works: put weight on the affected leg and press firmly into the floor. Gently massaging the muscle while stretching helps it release faster.
After the cramp passes, the muscle often feels sore for hours or even into the next day. This is normal. Light stretching and a warm compress can ease that residual tenderness.
Reducing Cramps Over Time
Prevention depends on the cause, but a few strategies help across the board. Regular stretching of the calves and thighs, particularly before bed if nighttime cramps are your issue, reduces how often cramps occur. Staying hydrated throughout the day matters, especially if you exercise or work in heat, but balance water intake with electrolytes rather than drinking plain water alone.
If you suspect a mineral shortfall, focus on dietary sources first. Bananas, potatoes, and leafy greens supply potassium. Dairy and fortified foods provide calcium. Nuts, seeds, and dark chocolate are rich in magnesium. For people who cramp frequently and eat a limited diet, a magnesium supplement is one of the more commonly tried options, though evidence for its effectiveness is stronger in pregnant women than in the general population.
Conditioning matters too. If your cramps happen during or after exercise, the most reliable fix is gradual progression. Increase distance, intensity, or duration by no more than about 10% per week, giving your muscles and nervous system time to adapt.
Signs That Need Medical Attention
Most leg cramps are benign, but a few patterns deserve a closer look. Severe cramping that doesn’t resolve with stretching, cramps that regularly interrupt your sleep and leave you exhausted during the day, or cramps accompanied by visible muscle weakness or loss of muscle mass all warrant a visit to your doctor. Cramps that began after exposure to a toxin, such as pesticides or industrial chemicals, need immediate medical attention.