How to Get Rid of Muscle Spasms: Relief and Prevention

Most muscle spasms stop within seconds to minutes using a combination of stretching, pressure, and temperature. The approach depends on where the spasm is happening and whether it’s a one-time event or a recurring problem. For spasms that keep coming back, the fix is usually upstream: hydration, mineral intake, or changes to how you move and sleep.

Stretching Away an Active Spasm

The fastest way to break a spasm is to lengthen the muscle that’s contracting. This works because a sustained stretch triggers a reflex that forces the muscle to relax. The key is holding the position long enough, typically 30 to 60 seconds, and resisting the urge to release early when the pain spikes.

Calf spasm: Keep your leg straight and pull the top of your foot toward your face. If you can stand, put your weight on the cramping leg and press your heel firmly into the floor. You can also face a wall, place your hands against it, and step the cramping leg back with the knee straight and heel flat. Slowly lean forward until you feel the stretch through the calf.

Hamstring spasm (back of thigh): Stand and shift your weight onto the cramping leg, pressing down firmly. If you can sit, extend the leg straight in front of you and reach toward your toes.

Quadriceps spasm (front of thigh): While holding a chair or wall for balance, pull the foot on the cramping side up toward your buttock. You should feel a deep stretch along the front of your thigh.

Back spasm: Lie on your back and gently pull both knees toward your chest. Hold there, breathing slowly. For a spasm on one side, pulling just that knee across your body toward the opposite shoulder can isolate the area better.

Heat, Cold, and When to Use Each

Heat relaxes tight muscle fibers and increases blood flow. Cold reduces inflammation and numbs pain. For a spasm that’s actively firing, heat is generally the better first choice because it promotes relaxation. Apply a warm towel, heating pad, or hot water bottle for 15 to 20 minutes. If you have access to a warm bath, water around 42°C (about 108°F) is the temperature used in clinical rehab settings, though any comfortably hot bath will help.

Cold works better when a spasm has left the muscle sore or slightly swollen afterward. A cold pack or cool water immersion for 15 to 20 minutes can reduce that residual ache. Wrap ice packs in a thin towel to protect your skin. Some people find alternating heat and cold effective for stubborn, recurring spasms, starting with heat and finishing with cold.

The Pickle Juice Trick

This one sounds odd, but it works surprisingly fast. Just one tablespoon of pickle juice has been shown to shut down experimentally induced cramps. The mechanism has nothing to do with hydration or salt replenishment. The acetic acid in the brine triggers nerve receptors in the back of your throat, which send a signal that interrupts the spasm reflex. It works in roughly a minute and a half. Vinegar, mustard, and other acidic liquids appear to use the same pathway, though pickle juice is the most studied.

Hydration and Electrolyte Balance

Dehydration alone doesn’t cause spasms in the way most people assume. A study published in BMJ Open Sport & Exercise Medicine found something counterintuitive: after participants lost 2% of their body mass through sweating, drinking plain water actually made their muscles more susceptible to cramping. The issue wasn’t the water itself but the dilution of electrolytes. When subjects drank fluids that replaced electrolytes, the increased cramp susceptibility reversed.

The practical takeaway: if you’re sweating heavily, plain water isn’t enough. You need sodium, potassium, and magnesium coming in alongside the fluid. Sports drinks, coconut water, or water with a pinch of salt and a squeeze of citrus all work. If your spasms tend to happen during or after exercise, pay attention to what you’re drinking, not just how much.

Magnesium and Other Key Minerals

Magnesium plays a direct role in muscle contraction and relaxation. When levels drop, you can experience numbness, tingling, and involuntary muscle contractions. The recommended daily intake is 310 to 320 mg for women and 400 to 420 mg for men, depending on age. Most people don’t hit that number through diet alone.

Magnesium citrate is one of the better-absorbed forms and has evidence supporting its use for cramp prevention. A Cochrane review found that magnesium citrate or lactate taken twice daily reduced leg cramps in pregnant women. Foods high in magnesium include dark leafy greens, nuts, seeds, beans, and whole grains. If you supplement, start on the lower end because high doses can cause loose stools.

Potassium and calcium matter too. Bananas get all the credit for potassium, but avocados, sweet potatoes, and white beans actually contain more per serving. Calcium-rich foods like yogurt and fortified plant milks round out the trio of minerals most relevant to spasm prevention.

Stopping Nighttime Leg Cramps

Nocturnal leg cramps are especially common and have a specific mechanical trigger. When you’re lying in bed, your foot naturally points downward, which shortens the calf muscle. In that shortened position, even a small involuntary nerve signal can set off a full cramp. This is why calf cramps at 3 a.m. are so much more common than, say, shoulder cramps.

A few minutes of light exercise before bed, like walking or pedaling on a stationary bike, can reduce the frequency of nighttime cramps. Stretching your calves before you get under the covers helps too. Some people find that sleeping with a pillow propping the feet up, or hanging the feet off the end of the bed, prevents the foot from dropping into that shortened position. If a cramp wakes you, forcefully pulling your toes toward your shin (dorsiflexion) is the fastest way to break it. Deep tissue massage of the calf after the cramp subsides can prevent it from returning the same night.

Over-the-Counter and Prescription Options

There are no over-the-counter muscle relaxants available in the United States. What you can buy without a prescription are anti-inflammatory painkillers like ibuprofen or naproxen, which help with the soreness a spasm leaves behind but don’t stop the spasm itself. Acetaminophen can dull the pain but similarly won’t address the underlying contraction.

Prescription muscle relaxants fall into two categories. Antispasmodics work on the brain and spinal cord to reduce the signals that cause sudden cramping. Antispastics work more directly on the muscle or spinal cord to reduce sustained tightness and involuntary contractions. Most of these medications cause drowsiness because they act as central nervous system depressants. They’re typically prescribed for short periods when spasms are frequent enough to interfere with sleep or daily function, not as a long-term solution for occasional cramps.

When Spasms Signal Something Else

Occasional spasms in the calves, feet, or hamstrings are almost always benign. But certain patterns warrant a closer look. Spasms that show up in the arms, hands, or trunk (rather than the legs) are less common and more likely to reflect an underlying issue. The same goes for spasms accompanied by muscle weakness that doesn’t resolve, visible twitching (fasciculations) that persists between spasms, or numbness and tingling that follows a specific nerve path down a limb.

Spasms that come with noticeably exaggerated or diminished reflexes, or that develop alongside significant changes in sensation, can point to nerve compression, spinal cord involvement, or other neurological conditions. Persistent, widespread spasms in someone with signs of chronic alcohol use or severe dehydration also fall into a different clinical category. In any of these situations, the spasm is a symptom, not the problem itself, and treating only the spasm will miss what’s driving it.