A muscle cramp is a sudden and involuntary contraction of one or more of your muscles. Muscle cramps can result in intense pain and leave you temporarily unable to use the affected muscles.
Common causes of muscle cramps include overuse and dehydration during physical activity in warm weather. Some medications and certain medical conditions also may cause muscle cramps.
You can usually treat muscle cramps at home with self-care measures.

Signs and symptoms of a muscle cramp include:
  • Sudden and sharp muscle pain (spasm, contraction), often in your legs
  • A hard lump of muscle tissue that you can feel or is visible beneath your skin
When to see a doctor
Muscle cramps usually disappear on their own, and are rarely serious enough to require medical care. However, if you experience frequent and severe muscle cramps or if your cramps disturb your sleep, see your doctor.

Overuse of a muscle, dehydration, muscle strain or simply holding a position for a prolonged period of time may result in a muscle cramp. Athletes who become fatigued and dehydrated while participating in warm-weather sports frequently develop muscle cramps. In many cases, however, the exact cause of a muscle cramp isn't identified.
Writer's cramp affects the thumb and first two fingers of your writing hand and results from using the same muscles for long periods. At home, you can develop muscle cramps in your hand or arm after spending long hours gripping a paintbrush or using a garden tool. A common type of muscle cramp — nocturnal cramps — occurs in your calf muscles or toes during sleep.
Muscle cramps in your legs can also result from:
  • Inadequate blood supply. Narrowing of the arteries that deliver blood to your legs (arteriosclerosis of the extremities) can produce cramp-like pain in your legs and feet while you're exercising. These cramps go away soon after you stop exercising and stand still.
  • Nerve compression. Compression of nerves in your spine (lumbar stenosis) also can produce cramp-like pain in your legs. The pain usually worsens the longer you walk. Walking in a slightly flexed position — such as you would employ when pushing a shopping cart ahead of you — may improve your symptoms.
  • Mineral depletion. Too little potassium, calcium or magnesium in your diet can contribute to leg cramps. Some diuretic medications prescribed for high blood pressure cause loss of potassium.
Muscle cramps are also part of certain conditions such as nerve, kidney, thyroid or hormone disorders, diabetes, hypoglycemia and anemia.

You can usually treat muscle cramps with self-care measures. Your doctor can show you stretching exercises that can help you reduce your chances of getting muscle cramps. Making sure you stay well hydrated also can help. For recurrent cramps that disturb your sleep, your doctor may prescribe a medication to relax your muscles.

If you have a cramp, these actions may provide relief:
  • Stretch and massage. Stretch the cramped muscle and gently rub it to help it relax. For a calf cramp, put your weight on your cramped leg and bend your knee slightly. If you're unable to stand, try pulling the top of your foot on the affected side toward your head while your leg is in a straightened position. This will also help ease a back thigh (hamstring) cramp. For a front thigh (quadriceps) cramp, use a chair to steady yourself and try pulling your foot on the affected side up toward your buttock.
  • Apply cold or heat. Use a cold pack to relax tense muscles. Use a warm towel or heating pad later if you have pain or tenderness, or take a hot bath.
These steps may help prevent cramps:
  • Avoid dehydration. Drink plenty of liquids every day. The exact amount depends on what you eat, your sex, your level of activity, the weather, your health, your age and any medications you may be taking. Fluids help your muscles contract and relax and keep muscle cells hydrated and less irritable. Drink fluids before any exercise activity. During the activity, replenish fluids at regular intervals, and continue drinking water or other fluids after you're finished.
  • Stretch your muscles. Stretch before and after you use any muscle for an extended period. If you tend to have leg cramps at night, stretch before bedtime.