Jarett Berry of the University of Texas Southwestern Medical Center in Dallas and colleagues tracked the fitness in 9,000 people for 18 years -- mean age 49.
Heart failure is when the heart can't pump enough blood, which is different from coronary heart disease when fatty deposits clog the coronary arteries.
Fitness was categorized into age- and sex-specific quintiles using Balke protocol treadmill time with the lowest quintile as low fitness. Fitness was also estimated in metabolic equivalents according to treadmill time.
Associations between midlife fitness and hospitalizations for heart failure and acute myocardial infarction -- heart attack -- after age 65 were assessed.
The researchers found the more fit people were while middle aged, the lower their risk of heart failure at age 65 and older.
"Low fitness levels earlier in life are particularly important for heart failure risk across the lifespan, and appear to be more important for heart failure risk than for coronary heart disease risk," Berry said in a statement.
The study was presented at an American Heart Association meeting.
Notable deaths of 2014 [PHOTOS]