Muscle spasms are caused by nerves that malfunction, according to the National Institutes of HealthOff Site Icon (NIH).
Nerves malfunctioning, according to the NIH, can be caused by:
Lack of minerals in your diet
Muscles not getting enough blood
Spinal cord injury
Straining or overusing a muscle
Cramps can be painful, but once the muscle relaxes, the pain will ease, according to the NIH.
Talk to your doctor for more information about what causes leg spasms.
These include: abnormal nerve activity during sleep which causes the muscle of the leg to cramp. excessive strain placed on leg muscles, such as when exercising, may cause the muscles to cramp at certain times. a sudden restriction in the blood supply to the affected muscles