Pregnant women have been urged to take extra care over their diet in light of new evidence that it affects an unborn child's risk of diabetes many decades later.
Scientists pinpointed a gene in rats that can be reprogrammed in the womb by an unbalanced diet.
The modification led offspring of protein-deficient mothers to develop type 2 diabetes, the most common form of the disease.
Researchers believe a similar effect is likely to occur in humans, possibly involving different aspects of diet.
Theoretically, the genetic changes induced by poor nutrition in the womb could be inherited and passed on to future generations.
Dr Susan Ozanne, from the Institute of Metabolic Science at Cambridge University, who co-led the research, said: "Having a healthy well-balanced diet is important at any time during your life.
"A healthy well-balanced diet is particularly important during pregnancy because of the impact on the baby long-term, and the potential impact on the grandchildren as well."
Processes that allow environmental factors, such as diet, to alter the activity of genes are known as "epigenetic" and are still not well understood.
They result in genes being chemically tagged or "marked" in ways that can permanently switch them on or off.
Evidence from animal studies and some research on human populations suggests that epigenetic effects can be transmitted from one generation to another.
One study of historical records from the Swedish village of Overkalix indicated that being undernourished in the womb or fed too well in early childhood could reduce the lifespan of grandchildren.
The new research is the first to trace epigenetic effects to a particular gene.
It was already known that dietary factors early in life, including before birth, can influence long-term metabolic health.
But scientists are still trying to understand how these effects occur.
The Cambridge team focused on a "master regulator" metabolism gene called Hnf4alpha.
The gene plays an important role both in the foetal development of the pancreas and the later production of insulin by "islet" cells in the organ.