Although the work focused on mice, it is believed to be just as relevant to humans.
Lead scientist Dr Brian Parks, from the University of California at Los Angeles (UCLA), said: "Our research demonstrates that body-fat responses to high-fat, high-sugar diets have a very strong genetic component, and we have identified several genetic factors potentially regulating these responses.
"Obesity has similar genetic signatures in mice and humans. Overall, our work has broad implications concerning the genetic nature of obesity and weight gain."
Dramatic increases in obesity over the past few decades have been linked to high-calorie sugar and fat-rich diets as well as 'couch potato' lifestyles.
But the new research indicates that body-fat responses to food are to a large extent hard-wired into our DNA.
The UCLA team looked at the effect of high-calorie diets on more than 100 strains of lab mice.
The scientists located 11 regions of the genetic code associated with obesity and fat gain due to diet. Several of these overlapped with genes identified in human studies.
"We measured the change in fat dynamically at five different points following a high-fat, high-sugar feeding, providing strong evidence for a genetically controlled body-fat set-point," said Dr Parks.
"Our use of inbred mice strains also enabled detailed analysis of the relationship between obesity traits, gene expression, intestinal flora and diet."
Dietary responses varied greatly across strains, according to the findings.
Increases in body fat as a proportion of weight ranged from zero to 600pc.
Most mice strains responded during the first four weeks of a high-calorie diet and did not accumulate more fat during the remainder of the study. This suggests they reached a natural upper threshold limit.
"We observed high heritability of about 80pc for body-fat percentage across the study timeline," said co-author Professor Jake Lusis, also from UCLA.
"Changes in body-fat percentage after high-fat, high-sugar feeding were also highly heritable, suggesting that dietary responses are strongly controlled by genetics."
The findings are consistent with generational patterns of body mass index and obesity seen in humans, said the researchers.