However good you are at losing weight on a diet, your body will work hard to compensate for lost fat as soon as you stop the regime, a new study finds.

Crash diets and yo-yo dieting have been linked to long-term weight gain as part of an evolutionary response to a scarcity of food.

The brain reacts to dieting by preparing for a period of starvation. Repeated diets tap into an evolutionary response that the body has when food supply is limited. Limited food makes people hungrier, making the urge to eat increase rapidly while dieting.

When the diet stops, however, the urge to eat carries on. This leads to overeating in the periods in between diets, researchers at the University of Exeter and the University of Bristol found.

The study is based on observations of animal behaviour when they know that food will be scarce in the future or whether it will be abundant. Although the study was a model of animal behaviour rather than human behaviour, the authors argue that as it is an evolutionary response, a similar mechanism is likely to occur in humans.

"Evolutionary approaches to understanding obesity typically assume that humans will have physiological and cognitive systems that evolved in natural (ancestral) environments and have not changed since then, and we know that maladaptive behaviours of various kinds can emerge from strategies that are adaptive in natural environments," the authors write in the paper published in the journal Evolution, Medicine and Public Health.

"Surprisingly, our model predicts that the average weight gain for dieters will actually be greater than those who never diet," says Andrew Higginson of Exeter and an author of the study.

"This happens because non-dieters learn that the food supply is reliable so there is less need for the insurance of fat stores."

"Our simple model shows that weight gain does not mean that people's physiology is malfunctioning or that they are being overwhelmed by unnaturally sweet tastes," says John McNamara of Bristol, another author of the study.

The findings come shortly after another paper published in the journal Nature that found that mice's gut bacteria were altered by yo-yo-style diets in a way that contributed to their overall weight gain.