Yo-yo dieting, the technique of repeatedly going on and off diets, may lead to weight gain as the brain interprets these periods as short famines and urges the body to store more fat for future shortages.
Researchers from the Universities of Exeter and Bristol in the UK conducted the study after the observation that animals respond to the risk of food shortage by gaining weight, which is why garden birds are fatter in the winter when seeds and insects are hard to find.
This may explain why people who try low-calorie diets often overeat when not dieting and so do not keep the weight off. By contrast, people who do not diet will learn that food supplies are reliable and they do not need to store so much fat, researchers said.
They studied a mathematical model of an animal that knows whether food is currently abundant or limited, but does not know when things will change, so must learn about the changeability before deciding how fat to be.
The model showed that if food supply is often restricted (as it is when dieting) an optimal animal - the one with the best chance of passing on its genes - should gain excess weight between food shortages.
"Our model predicts that the average weight gain for dieters will actually be greater than those who never diet," said Andrew Higginson from the University of Exeter.
"This happens because non-dieters learn that the food supply is reliable so there is less need for the insurance of fat stores," said Higginson.
Humans evolved in a world where food was sometimes plentiful and sometimes scarce - and in the latter case those with more fat would be more likely to survive.
Today, people can get into a vicious cycle of weight gain and ever more severe diets - so-called yo-yo dieting - which only convinces the brain it must store ever more fat.
The model predicts that the urge to eat increases hugely as a diet goes on, and this urge will not diminish as weight is gained because the brain gets convinced that famines are likely.
"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," said John McNamara from the University of Bristol.
"The brain could be functioning perfectly, but uncertainty about the food supply triggers the evolved response to gain weight," said McNamara.
"The best thing for weight loss is to take it steady. Our work suggests that eating only slightly less than you should, all the time, and doing physical exercise is much more likely to help you reach a healthy weight than going on low-calorie diets," said Higginson.
The study was published in the journal Evolution, Medicine and Public Health.