Getting active in mid-life could be as good for you as starting young when it comes to reducing the risk of an early death, researchers have suggested.
But experts say the study, which looked at people's patterns of exercise as they aged and their subsequent death records, also shows it does not do you good to rest on your laurels: the benefits fade once exercise declines.
"If you maintain an active lifestyle or participate in some sort of exercise over this window of time (from youth to middle age), you can reduce your risk for dying," said Dr Pedro Saint-Maurice, the lead author of the research, from the National Cancer Institute in the United States.
"If you are not active and you get to your 40s-50s and you decide to become active, you can still enjoy a lot of those benefits."
The study, published in the journal Jama Network Open, was based on data from more than 300,000 Americans aged 50 to 71 who undertook a questionnaire in the mid-1990s.
They were asked to estimate the extent of their moderate to vigorous leisure exercise at different stages of their life. Researchers then used national records to track who died in the years up to the end of 2011, and from what.
Exercise time per week by the ages of 40 to 61 is beneficial even if one had not started exercising from young.
The risk lowered for any cause of death when exercising seven hours a week when you start hitting the 40s.
After taking into account factors including age, sex, smoking and diet, the team found that those who were exercising into middle age had a lower risk of death from any cause in the years that followed than those who had never carried out any leisure exercise.
However, when the team looked at 10 different patterns in the way people were active over their life, they found a surprise.
Men and women who ramped up their activity gradually to about seven hours a week by the ages of 40 to 61 reduced their risk of death from any cause in the years that followed by about 35 per cent.
The benefit was similar to that seen for people who reached and maintained similar activity from their teens or 20s onwards, or who exercised at such a level when young and middle-aged but dipped in activity in their 30s.
Similar trends were identified looking at the relationship between patterns of exercise and two particular causes of death, cardiovascular disease and cancer, though the benefits were larger for the former than the latter.
However, the study found that the protective effect of exercise did not last forever: people whose levels of leisure exercise dwindled by middle age had no difference in the risk of an early death to those who had always been couch potatoes.
"If you have been active and you slowly decrease your exercise participation as you age, you lose a lot of the benefits that we know are associated with exercise," Saint-Maurice said.
While the team said the exercise levels recorded in the study were only broad estimates, the findings showed that patterns of exercise were important.
But the study has limitations, including that it is based on individuals recalling how active they were many years before, as well as problems of such data involving broad estimates - although the team did check whether people generally gave similar answers when asked to repeat the questionnaire after six months.
What is more, the research looked only at mortality, not other aspects of health such as levels of sickness and disease.
Dylan Thompson, a professor of human physiology at the University of Bath, who was not involved in the study, said it also did not consider exercise taken as part of daily life rather than for leisure.
Nonetheless, he said, the message was positive.
"This adds to the growing body of evidence about the importance of physical activity and exercise across the life course, and indicates that it is never too late to start."
Dr Charlie Foster, of the University of Bristol, said it was important to focus on not only physical activity but strength exercises too.
"Staying strong and getting stronger would also increase your health and decrease your risk of these chronic diseases," he said.