The causes of muscle cramps in the legs can be as disparate as dehydration, overexercise, trauma to the muscle, reactions to medications or sitting in one position for too long, according to Everyday Health. While leg cramps can occur during exercise, they often manifest as painful spasms at night.
Other causes of leg cramps include exposure to very cold temperature, kidney or thyroid disease, insufficient potassium or calcium, or blood flow problems related to peripheral artery disease, as stated by WebMD. In addition, pregnant women sometimes experience leg cramps due to insufficient magnesium. Leg cramps should be treated through stretching, application of heat or ice, drinking lots of fluids and taking over-the-counter pain medication.