The muscles in your legs are made up of bundles of fibers that alternately contract and expand to produce movement. A cramp is a sudden, involuntary contraction (tightening) of one of these muscles, typically in your calf. Cramps can last anywhere from a few seconds to several minutes. They can be mild, or intense enough to wake you out of a sound sleep. A sudden, painful muscle spasm in the leg is called a charley horse, which legend has it is named after baseball player Charlie “Hoss” Radbourn, who reportedly suffered from frequent cramps back in the 1880s.

Sometimes there is no obvious cause for a cramp. Exercise is a common trigger, especially after you’ve exercised for a long period of time or in the heat. Muscles that are tired or dehydrated become irritated and are more likely to cramp up. A deficiency of electrolytes such as magnesium or potassium in your diet can lead to more frequent cramping, by preventing your muscles from fully relaxing. The risk of a cramp increases during pregnancy, possibly because of circulatory changes and increased stress on the muscles from a growing belly. Age is another factor, with cramps becoming more frequent in middle age and beyond. Older muscles tire more easily, and they become increasingly sensitive to lower fluid volumes in the body. Cramps can also be a side effect of medicines like statins, which are used to treat high cholesterol.

Symptoms of muscle cramps

They can include:

Sudden pain and tightness in a muscle, typically in your calf
A temporary hard lump or twitching under the skin
Diagnosing muscle cramps

You should be able to treat a cramp on your own, but see a doctor if your cramps are severe, you get them often, or you have other symptoms (like numbness or weakness) along with them. Rarely, cramps can signal a problem with the spine, blood vessels, or liver.

Treating muscle cramps

Most cramps will go away on their own within a minutes. Massaging or gently stretching the muscle will help it relax. Heat is soothing to tense muscles. Apply a heating pad or warm wet washcloth to help loosen up the muscle.

To avoid leg cramps in the future, drink plenty of fluids before and during exercise. Muscles need fluid to contract and relax properly. Prevent tightness by warming up your leg muscles before you work out with some walking in place or a slow jog. After each workout, stretch out your leg muscles for a few minutes. Do another set of stretches before bed if you tend to get cramps while you sleep.