The exact cause of muscle cramps, also called a muscle spasm, is not known. They happen when one of your muscles or muscle groups, usually in your calf or thigh, suddenly tightens up. Muscle fatigue, poor conditioning, dehydration, depletion of electrolytes, or muscles that are cold may all play a role.
Cramps can be quite painful but they’re usually not serious and often go away on their own. You can ease the cramp by stopping whatever activity you were doing when it started and by gently stretching the muscle. Apply heat to tense or tight muscles, and apply ice to muscles that are tender or sore.