Leg pain can be due to a muscle cramp (also called a charley horse). Common causes of cramps include:
Muscle fatigue or strain from overuse, excessive exercise, or holding a muscle in the same position for a long time.
Dehydration or depletion of potassium, sodium, calcium, or magnesium.
Medications like diuretics, which can cause you to lose too much fluid or minerals, and cholesterol-lowering drugs called statins.
http://www.nlm.nih.gov/medlineplus/ency/article/003182.htm
Muscle spasms can cause cramps and are usually brought on by the following:
Muscle fatigue
Heavy exercise
Dehydration
Pregnancy
Hypothyroidism
Depleted magnesium or calcium stores or other metabolic abnormalities
Alcoholism
Kidney failure leading to uremia
Medications
http://www.nlm.nih.gov/medlineplus/ency/article/003193.htm