Years of life spent sitting on an office chair or a couch can have deadly health effects in the long run – but curling up with a regular cup of coffee might be a way to offset that harmful lifestyle.

A study of more than 10,000 people in the United States has found those who drink coffee daily may be protected from the negatives of sitting for six or more hours a day.

Compared to those who don't drink coffee and who sit this much, sedentary coffee drinkers are 1.58 times less likely to die of all causes as many as 13 years later.

Researchers at Soochow University in China say their study is the first to evaluate how the health benefits of coffee could counteract the increased risk of death associated with prolonged sitting.

Analyzing nationally representative long-term health data from the US, the team found that drinking coffee essentially cancels out the association between sedentary lifestyles, death from cardiovascular disease, and all-cause mortality.

That's pretty incredible given that studies suggest even bouts of exercise may not fully protect against the long-term health downsides of prolonged sitting, such as type 2 diabetes, heart disease, or stroke.

Of all 10,639 participants considered in the current study, those who sat more than eight hours a day faced an increased risk of death from all causes, and death from cardiovascular disease, compared to those who sat less than four hours a day.

That supports previous research, but here's the really interesting part that no other study has identified before: The associated harms of sitting existed "only among adults who did not consume coffee".

Those participants with a sedentary lifestyle who did drink coffee benefited from a reduced risk of death from cardiovascular disease no matter how many daily cups they consumed.

What's more, those who drank the most coffee of the lot (more than two and a half cups a day) also faced a lower risk of all-cause mortality compared to people who don't drink coffee but also sit for at least six hours.

The findings can't tell us why coffee has this potentially protective effect against the associated harms of sitting, but previous studies with massive datasets have connected the widely consumed beverage to longer and healthier lives in general.

Caffeine in the blood has been found to reduce the risk of developing type 2 diabetes or cardiovascular diseases.

Even decaffeinated coffee is rich in antioxidants that may help boost the metabolism and reduce inflammation. Certain compounds in a cup of joe may also protect the brain from degenerative diseases, like Parkinson's.

These are really promising associations, but the details behind coffee's health benefits, like ideal dosage, need to be explored further.

Earlier this year, a study found that people with colorectal cancer who drank at least five cups a day had a 32 percent lower chance of their disease returning than those who drank fewer than two cups a day.

What's more, that same study also found three to five cups of daily coffee was associated with the greatest reduction in all-cause mortality. After more than five cups, however, the benefits dropped off.

"Given that coffee is a complex compound, further research is needed to explore this miracle compound," researchers at Soochow conclude.

The study was published in BMC Public Health.