TL;DR: a muscle cramp is a sudden, involuntary contraction that lasts from a few seconds to a few minutes. To stop one, pause and stretch the contracted muscle, for example by pulling your toes towards you if it is the calf. To prevent them, build up training load gradually, drink through the day and, in long hot sessions, replace sodium. If they are very frequent, see your doctor.

A muscle cramp is a sudden contraction that hurts and nearly always goes away by itself within minutes. Here is why it happens, how to stop one once it has started and what you can do to get fewer, whether you train or wake up with one in the small hours.
What muscle cramps are
What are muscle cramps?
A muscle cramp is a sudden, involuntary contraction or spasm of one or more muscles. It comes on abruptly, hurts and leaves the muscle hard. It can strike any muscle, although it is most common in the thigh, calf, foot, hand, abdomen and ribcage.
How long does a cramp last?
Between a few seconds and a few minutes. It usually eases within a couple of minutes, although the muscle can stay tender until the next day. If it comes back several times in a row or lasts much longer, it is worth having a doctor look at it.
Causes of muscle cramps
Cramps are very common in athletes, though not only in them. Knowing what sets them off helps you work out which case is yours.

Why do cramps happen?
There is no single cause. The most common are a strained or tired muscle, a compressed nerve, poor blood supply to the muscle, dehydration or a large loss of salts, pregnancy and some medicines. Often several of them add up.
Cramps in sport
During exertion, the best-supported explanation today is neuromuscular fatigue: a tired muscle controls the contraction and relaxation signals less well. In long sessions in the heat, dehydration and the sodium lost in sweat may contribute. That is why cramps tend to show up at the end of a race, a match or a session harder than usual.
Why do I get cramps at night?
They happen to many people, athletes or not. Causes include changes in temperature, spending many hours standing or sitting, leaving your legs in awkward positions while you sleep and some drugs. It is usually harmless, but if it happens very often, tell your doctor.
Are leg cramps dangerous?
Almost never. See a doctor if they are very frequent, if they come with swelling, redness or weakness, if they start after a change of medication or if stretching does not help. A one-off cramp after exertion or an awkward position does not usually point to anything serious.
How to stop a cramp
How do you get rid of a leg cramp quickly?
Stop and stretch the muscle that has tightened. For the calf, pull your toes towards you or put your heel on the floor and lean your body forwards. Massage the area gently, apply warmth and walk slowly. It usually eases within seconds or a few minutes.
After the stretch, drink some water and do not strain the muscle again straight away: it may stay tender for a while.
How to prevent cramps
Gradual training and stretching
Match the intensity and length of your sessions to your current fitness so the muscle adapts bit by bit, without being forced. Stretching at the end helps it regain its length rather than staying contracted.
Hydration and salts
Drink through the day and before and after activity: the muscle needs fluid to work. In long sessions or in the heat, sweat carries away sodium, and a drink with salts does more than water alone. You can add a little salt to meals, but not if you have high blood pressure or heart or kidney problems, because too much salt can make them worse. Check with your doctor first.
The minerals you lose when you sweat are covered in why we need to replenish electrolytes, and which type of drink to choose in isotonic, hypotonic and hypertonic drinks. The hydration section has our options. The lemon isotonic powder, for example, is made with 40 g in 500 ml of water and per serving contains 31.2 g of carbohydrate, 153 mg of magnesium (41% of the reference intake) and about 1.5 g of salt.
What should you take for cramps?
Water and, in long sessions or when you sweat a lot, a drink with sodium. Day to day, foods with magnesium and potassium, such as nuts, pulses, bananas and leafy greens. An electrolyte supplement can help as support, but none guarantees you will not get them.
Does magnesium help with cramps?
The evidence is weak. For night cramps, reviews find no clear benefit, and in healthy athletes there is no proof that it prevents cramps. It may make sense if your intake is low. Magnesium contributes to normal muscle function, but that is not the same as stopping cramps.
Kit
Suitable clothes and shoes make the movement easier and stop you doubling the effort without noticing.
Campree: electrolytes and B vitamins in capsules
Campree combines magnesium bisglycinate, sodium bicarbonate, potassium chloride, zinc oxide and vitamins B1, B6 and B12. The daily dose of 2 capsules contains 100 mg of magnesium (27% of the reference intake), 218 mg of potassium, 202 mg of chloride, 115 mg of sodium and 10 mg of zinc, plus 1.1 mg of B1, 6.1 mg of B6 and 2.5 µg of B12.Magnesium contributes to normal muscle function and, together with vitamins B6 and B12, to the reduction of tiredness and fatigue. Vitamins B1, B6 and B12 contribute to normal energy-yielding metabolism.
When should you take Campree?
Before activity, at a daily dose of 2 capsules. It is a food supplement that provides electrolytes, zinc and B vitamins, not a treatment. It does not replace proper hydration, and you should not exceed the daily dose on the pack.