A leg cramp is a sudden, involuntary contraction of a muscle in your leg that causes sharp pain and temporary tightness. Most cramps hit the calf, though they can strike the thigh or foot too. They typically last a few seconds to several minutes and then release on their own, sometimes leaving soreness behind. Nearly everyone experiences them at some point, and they become more common with age.
What Happens Inside the Muscle
Leg cramps are neurogenic, meaning they originate in the nervous system rather than in the muscle tissue itself. Your motor neurons, the nerve cells that tell muscles to contract, begin firing uncontrollably. Instead of the normal cycle of contract-and-relax, the muscle locks into a sustained contraction you can’t voluntarily release. Two leading explanations exist for why this happens: one points to changes in excitability at the spinal cord level (a central origin), and the other to spontaneous misfiring of the nerve at the muscle itself (a peripheral origin). Recent experimental work supports the central origin theory, suggesting something goes wrong with the signals traveling from your spine to the muscle.
This is why a cramp feels so different from the burn of a hard workout. During exercise, you choose to push your muscle. During a cramp, your nervous system hijacks the muscle and forces it to contract at maximum intensity without your permission.
Exercise Cramps vs. Nighttime Cramps
Not all leg cramps share the same trigger, and the distinction matters. Exercise-associated cramps tend to strike the specific muscles you’re working hardest. They develop when fatigue disrupts the balance between two sensory systems in your muscles: one that encourages contraction (muscle spindles) and one that inhibits it (Golgi tendon organs). As fatigue builds during prolonged or intense exercise, the “contract” signal ramps up while the “relax” signal fades. You may notice small twitches or fasciculations before a full cramp sets in. This has been called the “cramp-prone state,” and it explains why cramps tend to hit late in a race or game rather than at the start.
Nighttime leg cramps, by contrast, happen at rest and often jolt you awake. The risk rises with age, during pregnancy, and with prolonged inactivity. Cramps at rest have been linked to shifts in blood sodium levels and fluid balance, which is why they’re relatively common in people undergoing dialysis. The key difference: exercise cramps are local (confined to the muscles you were using), while cramps caused by systemic electrolyte problems can be more widespread, affecting multiple muscle groups at once.
Common Causes and Triggers
For many people, no single clear cause explains their cramps. But several factors consistently raise the risk:
- Dehydration. Not drinking enough fluid, especially during hot weather or illness, can set the stage for cramping.
- Muscle fatigue. Overworking a muscle or holding it in one position for a long time increases vulnerability.
- Inactivity. Sedentary lifestyles are a surprisingly common contributor, particularly for nighttime cramps.
- Pregnancy. Leg cramps are frequent during the second and third trimesters, likely due to a combination of extra weight, circulation changes, and mineral shifts.
- Medications. Diuretics (water pills), blood pressure medications, cholesterol-lowering drugs, oral contraceptives, and even high caffeine intake can all contribute. Stimulants like nicotine and certain asthma inhalers with airway-opening effects are also on the list.
The Electrolyte Question
You’ll often hear that low magnesium, potassium, or calcium causes leg cramps. The reality is more nuanced. There is no proven association between routine electrolyte abnormalities and common muscle cramps, and no standard blood test can diagnose the problem. Severe sodium depletion, the kind seen in medical settings like dialysis, can trigger generalized cramping. But for the average person waking up with a charley horse, a mineral deficiency is rarely the confirmed explanation.
That said, staying well-hydrated and eating a balanced diet that includes potassium-rich foods (bananas, potatoes, leafy greens) and magnesium sources (nuts, seeds, whole grains) is still reasonable. These nutrients support normal muscle function even if a specific deficiency isn’t driving your cramps.
How to Stop a Cramp in the Moment
When a cramp strikes, your instinct is to grab the muscle and freeze. Instead, actively stretch it. For a calf cramp, the most effective move is straightening your leg and pulling your toes up toward your shin. You can do this standing or sitting. If you can reach your foot, gently pull the toes back with your hand. Walking on your heels also forces the calf to lengthen and can break the spasm.
Once the worst of the contraction passes, massage the area to help the muscle relax fully. You can apply ice wrapped in a towel if the muscle still feels tight, or use a heating pad if soreness lingers. Elevating the leg afterward helps reduce any residual discomfort. Most cramps resolve within a few minutes, though the muscle may feel tender for hours or even into the next day.
Preventing Cramps Over Time
Regular stretching is the single most accessible preventive measure. Stretching your calves and hamstrings before bed, particularly if you’re prone to nighttime cramps, can reduce how often they occur. Light activity during the day, even a short walk, helps keep the muscles engaged and less prone to misfiring at night.
Hydration matters, especially if you exercise heavily, work outdoors, or take diuretics. Drinking water throughout the day rather than catching up at night reduces the likelihood of both cramps and disrupted sleep.
One newer finding is worth noting. A 2025 review highlighted in American Family Physician found that vitamin K2 (a form called menaquinone-7), taken as a 180-microgram supplement in the evening, cut the average number of nighttime leg cramps roughly in half in adults 65 and older. In the study, participants went from about 2.6 cramps per week down to less than one, while the placebo group’s cramps actually increased. The benefit appeared within the first week and continued growing over two months. Vitamin K2 has few side effects, but it interferes with the blood thinner warfarin and should not be combined with it.
When a Cramp Might Be Something Else
Most leg cramps are harmless, if painful. But certain symptoms suggest something beyond a simple muscle spasm. A deep vein thrombosis (DVT), or blood clot in the leg, can mimic cramping. The key differences: DVT pain tends to be persistent rather than coming in a sudden burst and releasing. It’s often accompanied by visible swelling in the leg, skin that looks red or purple, and a feeling of warmth in one specific area. A regular cramp doesn’t cause these changes.
DVT can sometimes produce no symptoms at all, which makes the warning signs worth knowing. If cramping-type pain in your leg comes with swelling, discoloration, or warmth that doesn’t resolve, that warrants medical attention. And if you develop sudden shortness of breath, chest pain, a rapid pulse, or cough up blood, those are signs a clot may have traveled to the lungs, which is a medical emergency.
Cramps that happen frequently, resist stretching, or occur in unusual patterns (affecting multiple limbs, lasting many minutes, or worsening over weeks) can also signal nerve or circulation problems that deserve a closer look.

