Women who drink two or more cups of coffee a day are less likely to get depressed, research suggests.
It is not clear why it might have this effect, but the authors believe caffeine in coffee may alter the brain's chemistry. Decaffeinated coffee did not have the same effect.
The findings, published in Archives of Internal Medicine, come from a study of more than 50,000 US female nurses.
The experts are now recommending more work to better understand the link.
And they say it is certainly too soon to start recommending that women should drink more coffee to boost mood.
The Harvard Medical School team tracked the health of the women over a decade from 1996 to 2006 and relied on questionnaires to record their coffee consumption.
Just over 2,600 of the women developed depression over this time period.
More of these women tended to be non- or low-coffee drinkers rather than frequent coffee consumers.
Compared with women who drank one cup of caffeinated coffee or less per week, those who consumed two to three cups per day had a 15% decreased risk of developing depression.
Those who drank four or more cups a day cut their risk by 20%.
Regular coffee drinkers were more likely to smoke and drink alcohol and were less likely to be involved in church, volunteer or community groups. They were also less likely to be overweight and have high blood pressure or diabetes.
Even after controlling for all of these variables, the trend of increasing coffee consumption and lower depression remained.
The researchers say their findings add weight to the work of others which found lower suicide rates among coffee drinkers.
They suspect caffeine is the key player - it is known to enhance feelings of wellbeing and energy.
And it has a physical effect on brain function and transmission by altering chemical pathways, like those involving adenosine. But more research is needed to show if this might mean it is useful for warding off depression.
Alternatively, it might be that people with low moods chose not to drink coffee because it contained caffeine, point out the researchers. One of the common symptoms of depression is disturbed sleep, and caffeine can exacerbate this because it is a stimulant.
Too much caffeine can also increase feelings of anxiety.
Prof Bertil Fredholm, an expert in pharmacology and physiology at Sweden's Karolinska Institute, said the findings were reassuring for coffee-lovers.
"This fits nicely with a lot of the previous work and what we know about caffeine and the brain. It blocks adenosine, which produces a similar effect to increasing dopamine production. And it's becoming increasingly clear that the dopamine-rich areas of the brain are much more important in depression than previously thought.
"Despite valiant efforts to show how dangerous coffee is for us, it is not proving so.
"This removes yet another anxiety regarding caffeine use. Drunk in moderation, the evidence is strong that it is not one of the things we do that is going to damage your health."