The team used survey data from more than 40,000 adults in the United States between 1999 and 2018, who were asked about all the food and drink they consumed on at least one day, including whether they drank coffee, how much and when.
This information was then linked with records of deaths and cause-of-death over nine to 10 years.
The team found that about 36% of people in the study were morning coffee drinkers - primarily drinking coffee before noon, 16% of people drank coffee throughout the day and 48% were not coffee drinkers.
Compared with people who did not drink coffee, morning coffee drinkers were 16% less likely to die of any cause and 31% less likely to die of heart disease.
However, there was no reduction in risk for all-day coffee drinkers compared with non-coffee drinkers.
It is possible that coffee drinking in the afternoon or evening disrupts the circadian rhythm that helps with sleep, due to its suppressing effect on melatonin, an important sleep-inducing mediator in the brain.