Gaining weight in your 20s, 30s and early 40s increases the risk of an early death by more than a fifth, research suggests.

Experts found that people who became obese between the age of 25 and around 47 had a 22% higher risk of dying early from any cause, and a 49% increased risk of dying from heart disease.

The study also found that putting on weight from middle age increases the chance of dying young, but losing weight and going from obese to a healthy weight between middle and old age was risky too.

For the study, published in the British Medical Journal (BMJ), experts analysed data for 36,051 people who were aged 40 or over at the start of the study.

They were weighed and measured at the start, and told researchers how much they weighed at 25 and 10 years previously, when the group was typically aged 47.

During a 12-year follow-up, 10,500 deaths were recorded.

After stripping factors that may influence results, experts found that, compared with people of a healthy weight, those who became obese between the age of 25 and middle adulthood had a 22% higher risk of early death from any cause and a 49% increased risk of death from heart disease.

People who lost weight and went from being obese to a healthy weight over the same period had no increased risk.

However, the same was not true for people who lost weight when they were older.

Those who moved from being obese to a healthy weight between middle age and later in life had a 30% increased risk of dying early from any cause and a 48% increased risk from heart disease.

Overall, being obese during the entirety of adult life carried the biggest risks – with up to a 72% increased danger of dying young.

The authors concluded: “Stable obesity across adulthood, weight gain from young to middle adulthood, and weight loss from middle to late adulthood were associated with increased risks of mortality.

“The findings imply that maintaining normal weight across adulthood, especially preventing weight gain in early adulthood, is important for preventing premature deaths in later life.”

The study among US citizens was led by a team from the School of Public Health at Huazhong University of Science and Technology in China.

Tam Fry, spokesman for the National Obesity Forum, said: “The message to maintain a healthy weight throughout life couldn’t be clearer.

“Some 12 years ago the well-respected Foresight Report first stunned the UK by predicting that being fat could knock 13 years off your life.

“But given the continuing rise of obesity-related hospital admissions, few people appear to have listened.”