Sleeping too much or too little can increase the likelihood of becoming obese, researchers have discovered.
The study found abnormal sleeping patterns increased the risk of being overweight for those genetically predisposed to obesity.
The effect was seen regardless of diet, health or socio-demographic group.
The University of Glasgow study also found no clear link between sleep duration and body weight in those with a low genetic risk of obesity.
Researchers looked at the effects of a short sleep of less than seven hours a night and a long sleep - more than nine hours - along with daytime napping and shift work.
They found that in people with a high genetic risk of obesity, both short-sleep and long-sleep durations further increased risk of carrying excess weight, compared with people who slept for normal durations of between seven and nine hours a night.
Long sleepers with a risk of obesity were about 4kg heavier and short sleepers were about 2kg heavier than those with a similarly high genetic obesity risk with normal sleep durations.
The negative affect happened irrespective of what subjects ate, their health concerns or socio-demographic factors, the research team said.
The findings, based on data from almost 120,000 UK Biobank participants, showed no obvious link between sleep duration and body weight in those considered to be at a low genetic risk of obesity.Image copyright Thinkstock Image caption Shift work or napping during the day appeared to have a substantial adverse effect
Dr Jason Gill, from the Institute of Cardiovascular and Medical Sciences, said: "These data show that in people with high genetic risk for obesity, sleeping for too short or too long a time, napping during the day and shift work appears to have a fairly substantial adverse influence on body weight.
"However, the influence of adverse sleep characteristics on body weight is much smaller in those with low genetic obesity risk - these people appear to be able to 'get away' with poorer sleep habits to some extent."
Co-author Dr Carlos Celis said: "It appears that people with high genetic risk for obesity need to take more care about lifestyle factors to maintain a healthy body weight.
"Our data suggest that sleep is another factor which needs to be considered, alongside diet and physical activity."
The study, said to be the first to examine the interactions of sleeping habits and genes with obesity, is published in the American Journal of Clinical Nutrition.