Maybe it isn't.
The standard theory: muscle cramps are caused by loss of fluids and electrolytes, which alters fluid balance in the body and increases the excitability of nerves.
The "new" theory: muscles cramps result from "altered neuromuscular control," which can be triggered by a variety of factors, including genetic predisposition, damaged or fatigued muscles, starting too fast, and not tapering enough -- none of which have anything to do with hydration or electrolytes. [...]
A few years ago, researchers at North Dakota State University published a study showing that dehydrating subjects by 3% of their initial body weight didn't change their susceptibility to muscle cramps (as measured by threshold frequency). Now, in a new British Journal of Sports Medicine study, they've extended those results to a greater degree of dehydration: their 10 subjects reached an average dehydration of 4.7% (greater than 3% is "significant" dehydration, while greater than 5% is "serious") after almost four hours of exercise in very hot conditions. Crucially, they exercised only with their non-dominant limbs, while the cramp testing was performed on their dominant leg, so that muscle fatigue/damage could be eliminated as a triggering factor.
The result: no difference in cramp susceptibility or intensity, despite an extreme dehydration protocol that saw them lose about 4 g of sodium! The researchers conclude that their data supports the "altered neuromuscular control" theory.
Even the older research that did find it more plausible that electrolytes were a cause wasn't very adamant that's the [only] cause, e.g.:
Consumption of a carbohydrate-electrolyte beverage before and during exercise in a hot environment may delay the onset of EAMCs [Exercise-associated muscle cramps], thereby allowing participants to exercise longer. However, it appears that dehydration and electrolyte loss are not the sole causes of EAMCs, because 69% of the subjects experienced EAMCs when they were hydrated and supplemented with electrolytes.
There are a few [not very well controlled, IMO] experiments from the 1920s and 30s (three papers to be more precise) that did find a role for sodium depletion in some cases of mild cramping. The most controlled of these (published in 1936) involved sodium depletion for 10 days (daily sweating and virtually no intake), which is hard to argue is that common in most cramp suffers. The original paper notes that the level of sodium depletion involved led to quite a few other symptoms:
Such deprivation led to aberrations of flavour, cramps, weakness,
lassitude, and severe cardio-respiratory distress on exertion. The nitrogen balance became negative and the blood urea rose.
And despite the severe sodium depletion, the cramps were mild but generalized:
These muscular cramps were not of the very severe localized type which are
said to affect stokers and miners (Moss, 1923-24), but were widespread,
frequent, not very painful, and generally controllable. Any muscle in
the body was liable to go into spasmodic contraction, especially if some
little effort was demanded of it (Moss, 1923-24). “ Coughed a little
over something, cramps round chest, mild.” * R.B.N. experienced
occasional cramps in the muscles lining the floor of the mouth but the
extremities were most affected, and it was possible sometimes by suitable
movement of the toes to alternate the spasms for hours on end between
the extensor and flexor muscles. Perhaps the most characteristic of all
were the manual cramps. R.A.M. experienced “ constant mild cramps
of the fingers and thumb when using forceps at the balance,” * and R.B.N.
found that he “ cramped quickly when working, telephoning, or using
So that's why I say these types of cramps probably have little relevance for those experienced by most people.
I'm not sure there any studies for potassium. The paper reviewing the sodium evidence notes:
Mechanisms in heat cramping remain murky. Sodium loss contracts extracellular fluid space and may alter ion channels to make neuromuscular junctions or muscle units hyperexcitable, thus evoking
involuntary and sustained contractions, or heat cramping. And, not all camps buy salt loss for cramps. Bananas, for example, remain popular in some football camps, to prevent heat cramping by ‘replacing potassium’. But here, bananas are yellow herrings because little potassium is lost in sweat. The same applies to calcium and magnesium. Sweat after all, is mainly water and salt (sodium chloride).
And do note that his latter paper is written by a Gatorade consultant.
One 2009 review in clear opposition to relevance of electrolytes-water for the usual exercise-related muscle cramps notes:
In summary, dehydration and electrolyte depletion are often considered together (and recently together with muscle fatigue) as the “triad” causing EAMC. The key components of this hypothesis (fig 1) are that electrolyte (mainly sodium) depletion through excessive sweat sodium loss together with dehydration causes EAMC. However, results from prospective cohort studies consistently show that athletes suffering from acute EAMC are not dehydrated, neither do they have disturbances in serum osmolality or serum electrolyte (notably sodium) concentrations. Furthermore, sweat sodium concentrations measured during exercise in 23 reported cases with a past history of EAMC are not higher than those reported in many other studies. Both electrolyte depletion and dehydration are systemic abnormalities, and therefore would result in systemic symptoms, as has been observed in other clinical conditions. However, in EAMC, the symptoms classically are local and are confined to the working muscle groups. Thus, the available evidence to date does not support the hypotheses that electrolyte depletion or dehydration cause EAMC — therefore an alternate hypothesis for the aetiology of EAMC has to be considered.
Suffice to say that this field is still quite contested... and plagued by conflicts of interest. Witness a 2019 paper finding that a magic electrolyte formula (contents not disclosed) from a pharma company absolutely does lower the risk of cramps after exercise compared to water. Study funded by aforementioned pharma company, of course. And the press reported this as "water after exercise increases risk of cramps" (by diluting the electrolytes in your body, of course), arguably due to the authors' summary.
And while most of the previous material was about exercise-related cramps, even for the nocturnal cramps more often experienced by the elderly, the role of electrolytes appears uncommon; according to a 2007 review:
Muscle cramps, notably nocturnal leg cramps, are common symptoms experienced by general medical patients, particularly the elderly. Their etiology is varied; most commonly, these cramps are idiopathic. With the notable (and relatively rare) exceptions of serious electrolyte imbalances including hypokalemia, hypomagnesemia and hypocalcemia, these cramps are typically benign in nature. [...]
The second recent study to challenge the notion that diuretics [which promote a loss of electrolytes through urine] are a common cause of muscle cramps was a cross‐sectional survey of 365 general medical patients. Although the prevalence of leg cramps in this cohort was 50%, no associations were found between these cramps and any medication except analgesics that were used to treat the cramps. [...]
Nevertheless, a review of the Physicians' Desk Reference database (available at www.pdr.net) suggests a consistent association between diuretics and muscle cramps. [...]
The mechanism of diuretic‐associated cramping (if such an entity truly exists) is likely related to hypokalemia, hypomagnesemia, or volume contraction (with or without metabolic alkalosis). Hypocalcemia is a possible cause during therapy with loop‐diuretics such as furosemide, but is unlikely with the hypocalciuric thiazide‐type diuretics. Interestingly, potassium‐sparing diuretics, such as amiloride, are also associated with cramping. Thus volume contraction appears to be the one mechanism that is common to all classes of diuretics.
A 2012 new large-scale investigation did point to some epidemiological associations between cramps and diuretics:
Cramp treatment was substantially more likely in the year following introduction of LABAs [long-acting β2-agonists], potassium-sparing diuretics, or thiazide-like diuretics, and 60.3% of quinine users (individuals experiencing cramp) received at least 1 of these medications during a 13-year period. In contrast, statin and loop diuretic associations were small. Physicians should be mindful that the use of these medications may worsen symptoms in patients experiencing nocturnal leg cramps.
And they also have some comments on putative mechanisms:
Physicians may be surprised that potassium-sparing diuretics have a stronger link to cramp treatment than loop diuretics. Yet, hyperkalemia facilitates neuronal excitation, and hypokalemia suppresses motor neuron activity. β2-Agonists are known to have a stimulatory effect on motoneurons, and β2-adrenergic receptors are found on peripheral nerves.