Muscle spasms, or cramps, are involuntary contractions of the muscles. They are much more serious than muscle twitches, which occur due to fatigue, and can become a medical condition if chronic. Muscle spasms are essentially an imbalance of minerals and electrolytes in the bloodstream.
Excessive dehydration, particularly in leg muscles, upsets the mineral and electrolyte balance in the blood, which raises the possibility of muscle cramps occurring.
Excessive exercise, especially in endurance sports, uses up the minerals and electrolytes that are in the blood stream quickly, resulting in leg cramps.
Muscle cramps can also occur when a muscle has been in one position for a long period of time. For example, people get muscle cramps in their legs when they sit in front of the computer for extended periods of time.
Many medications have muscle cramps listed as a side effect. These drugs, most often, use up or somehow affect the mineral and electrolyte levels in your blood. Consult your doctor if you experience muscle cramps after taking medication.
Many diseases, such as multiple sclerosis, anemia, diabetes, kidney disease, and thyroid disease, can cause muscle spasms.