It's well known that overindulging on high-calorie food can lead to the number on the scales creeping up.
But a study on mice shows that while under stress, watching what you eat may be even more important.
Gorging on pizza, burgers and chips is more likely to lead to weight gain if you are stressed, the research suggests.
Researchers discovered a high-calorie diet when combined with stress resulted in more weight gain than in a stress-free environment.
Professor Herbert Herzog, from the Garvan Institute of Medical Research in Sydney, Australia, led the trial.
He said: 'This study indicates that we have to be much more conscious about what we're eating when we're stressed, to avoid a faster development of obesity.
'This really reinforced the idea that while it's bad to eat junk food, eating high-calorie foods under stress is a double whammy that drives obesity.'
Professor Herzog, who described the findings as a 'vicious cycle', said when stressed most people will reach for high-calorie foods high in sugar and fat.
The researchers looked at different areas of the brain in mice while feeding them a calorific diet.
Food intake is mainly controlled by a part of the brain called the hypothalamus, the team of scientists revealed.
While another part of the brain - the amygdala - processes emotional responses, including anxiety.
Stressed mice became obese 'more quickly' than those who consumed the same high fat food in a stress-free environment.
It unclear what the stressors were or how many calories were consumed in proportion to body mass, and therefore how these factors would translate to humans.
Tests showed a molecule called NPY played a crucial role in the weight gain, as it reduced their ability to burn energy through heat.
The brain produces NPY, short for Neuropeptide Y, naturally in response to stress, stimulating the need to eat in humans as well as mice.
Study co-author Dr Kenny Chi Kin Ip said: 'We discovered that when we switched off the production of NPY in the amygdala, weight gain was reduced.
'Without NPY, the weight gain on a high-fat diet with stress was the same as weight gain in the stress-free environment.
Dr Ip, whose findings were published in the journal Cell Metabolism, added: 'This shows a clear link between stress, obesity and NPY.'
The team analysed the nerve cells that produce NPY in the amygdala to see why there is a boost of it during stressful periods.
They found they had receptors - or 'docking stations' - for insulin, a hormone that controls bloody sugar levels.
Under normal conditions, the body produces insulin after a meal, which helps cells absorb glucose from the blood.
It also sends a 'stop eating' signal to the hypothalamus, the part of the brain which controls eating, the team said.
They found chronic stress alone raises blood insulin.
But in combination with a high-calorie diet, the insulin levels were ten times higher than mice that were stress-free and received a normal diet.
The study showed that the prolonged, high levels of insulin in the amygdala caused the nerve cells to become desensitised to insulin.
Without the ability to detect insulin, more NPY was created.
Other scientific studies have shown higher levels of NPY can lead to cravings for carbohydrates and reduce the feeling of fullness.
Source: The Daily Mail