A cramp is a sudden, involuntary, and painful contraction of a muscle or part of a muscle that typically resolves on its own within seconds to minutes. You can often feel or even see the muscle tighten into a hard knot under the skin. While most cramps are harmless, they can be intensely painful in the moment, and some people experience them frequently enough to disrupt sleep, exercise, or daily life.
What Happens Inside the Muscle
A cramp isn’t just a muscle problem. It starts with the nerves that control the muscle. Normally, your spinal cord balances two competing signals: excitatory signals that tell muscle fibers to contract and inhibitory signals that keep contractions in check. During a cramp, this balance breaks down. The motor neurons that fire your muscle become hyperexcitable, and a self-sustaining feedback loop takes over. The muscle contracts, which compresses sensory nerve endings within it, which sends signals back to the spinal cord that amplify the contraction further.
This loop is why a cramp feels so different from a normal muscle contraction. You can’t simply decide to relax the muscle. The motor neurons are firing on their own, driven by persistent electrical currents in the spinal cord that keep the cycle going until something interrupts it, usually stretching the muscle or waiting it out.
The Most Common Triggers
Muscle fatigue is the trigger with the strongest scientific support. When a muscle is overworked or held in a shortened position, the inhibitory signals from structures called Golgi tendon organs weaken while excitatory signals from muscle spindles stay high. This imbalance creates the conditions for a cramp. Researchers can reliably induce cramps in a lab by having people sustain contractions in shortened muscle positions, which is why your calf is so vulnerable when your foot is pointed downward.
The old explanation that cramps come from dehydration or low electrolytes has not held up well under scrutiny. A study of 82 marathon runners found no difference in sodium or potassium levels between those who cramped and those who didn’t, either before or after the race. A larger study of 210 Ironman triathletes reached the same conclusion. Another controlled experiment gave athletes a carbohydrate-electrolyte drink (containing over 1,600 mg of sodium per serving) during exercise and compared cramp rates to a trial where participants were deliberately under-hydrated. There was no significant difference in how many people cramped. One fundamental problem with the electrolyte theory: cramps almost always hit specific, localized muscles. A body-wide shortage of sodium or potassium doesn’t explain why only your left calf seizes up.
That said, severe electrolyte disturbances from prolonged illness, vomiting, or certain medications can still contribute to cramping. The evidence mainly challenges the idea that ordinary sweating and mild dehydration are to blame for the cramps most people experience.
Nocturnal Leg Cramps
Nighttime leg cramps are remarkably common, affecting 50 to 60 percent of adults at some point. They typically strike the calf or the small muscles of the foot and can jolt you awake with sharp pain that lingers as soreness for hours afterward.
The leading explanation involves the position of your foot during sleep. When you’re lying down, your foot naturally points downward, which places the calf muscle in its most shortened position. In that state, even a small, uninhibited nerve signal can trigger a full cramp. Some researchers have also suggested that modern lifestyles play a role: we rarely squat deeply the way humans historically did, so the tendons and muscles of the lower leg don’t get regularly stretched to their full length. Over time, this may make them more cramp-prone.
Menstrual Cramps Are a Different Process
When people say “cramps,” they sometimes mean the lower abdominal pain that comes with a menstrual period. These cramps involve a completely different type of muscle tissue. The uterus is made of smooth muscle, not the skeletal muscle in your legs and arms, and the mechanism is chemical rather than neurological.
At the start of a period, the lining of the uterus releases signaling molecules called prostaglandins. These trigger strong contractions of the uterine wall and constrict the blood vessels that supply it, temporarily cutting off oxygen. The combination of intense squeezing and reduced blood flow produces the deep, aching pain of menstrual cramps. Pain intensity tracks directly with prostaglandin levels: people with more severe cramps have measurably higher concentrations of these molecules in their uterine tissue.
Cramps vs. Spasms vs. Strains
These terms get used interchangeably, but they describe different things. A cramp is an involuntary contraction that’s painful and self-limiting, usually lasting seconds to a few minutes. A spasm is also an involuntary contraction, but the term is broader and can include contractions that aren’t necessarily painful (like an eyelid twitch). A strain is actual physical damage to muscle fibers or the tendons attaching them to bone. Strains cause pain that worsens with movement and persists for days or weeks, while a cramp’s pain resolves once the contraction stops, sometimes leaving only mild residual soreness.
How to Stop a Cramp in the Moment
Stretching is the fastest way to break the feedback loop driving a cramp. You’re essentially forcing the muscle to lengthen, which activates those inhibitory Golgi tendon organ signals and overrides the runaway motor neuron firing.
For a calf cramp, the most common type, keep your leg straight and pull the top of your foot toward your face. Alternatively, stand facing a wall with one leg back, heel flat on the floor, and lean forward until you feel the stretch in your calf. Hold either position for 30 to 60 seconds. You can also simply stand and press your full weight onto the cramped leg.
For a cramp in the back of your thigh, standing with your weight on the affected leg and pressing down firmly helps. Gentle massage during and after stretching can ease residual tightness. Applying heat to a cramped muscle helps it relax, while ice afterward can reduce any lingering soreness.
Does Magnesium Help?
Magnesium is one of the most popular supplements marketed for cramp prevention, but the evidence is mixed. A randomized, placebo-controlled trial gave adults with nocturnal leg cramps 226 mg of magnesium oxide daily for 60 days. Both the magnesium group and the placebo group saw significant reductions in cramp frequency, which is common in cramp studies because cramps naturally wax and wane. The magnesium group did see a slightly greater reduction (about 3.4 fewer cramps per week compared to 2.6 in the placebo group), and cramp duration also improved. However, pain intensity during cramps was no different between the two groups.
The modest benefit suggests magnesium may help some people, particularly if their intake is already low, but it’s not a reliable fix for everyone.
When Cramps Signal Something Else
Most cramps are benign, but frequent or severe cramps can sometimes point to an underlying condition. Nerve damage from diabetes or compressed nerves in the spine can cause motor neurons to misfire. Liver disease and kidney disease can impair the body’s ability to clear metabolic waste and maintain mineral balance, both of which affect muscle membrane stability. Inherited abnormalities in sodium, potassium, calcium, or chloride channels can make muscles more excitable from birth. Peripheral artery disease reduces blood flow to the legs and can cause cramp-like pain during walking.
The pattern matters more than any single cramp. Cramps that come on during walking and resolve with rest suggest a circulation problem. Cramps that are getting progressively more frequent or spreading to multiple muscle groups warrant closer attention. Occasional cramps in your calves after a long run or in the middle of the night are, for most people, just part of having a body.

