A cramp is a painful, continual, involuntary contraction of a muscle. They are generally caused by muscle fatigue (often from attempting to keep the affected part of the body in the same position for a long period of time), but are also commonly caused by low potassium or low sodium, often due to dehydration or lack of glucose. They are also a common secondary symptom of menstruation and gastroenteritis. However, they can be a symptom of a more serious illness, such as multiple sclerosis or kidney disease. As such, the symptom is not of much help in a differential diagnosis.
Muscles generally work in pairs and, for one muscle to contract, the other one must relax. Cramps generally occur when one muscle in the pair cannot relax properly. Muscles actually have to use energy to relax as well as contract, and magnesium is also vital to this process. Attempting to force a muscle to stretch can result in tearing the tissue instead.
Cramps can usually be relieved by light stretching and massage if the cramp is not severe. However, rest, fluids and salt are always appropriate. In severe cases, Vitamin B complex, lidocaine and calcium channel blockers are often effective.