Breastfeeding can halve the risk of post-natal depression, according to a large study of 14,000 new mothers.
However, there is a large increase in the risk of depression in women planning to breastfeed who are then unable to do so.
The study, published in the journal Maternal and Child Health, called for more support for women unable to breastfeed.
A parenting charity said mental health was a "huge issue" for many mothers.
The health benefits of breastfeeding to the baby are clear-cut and the World Health Organization recommends feeding a child nothing but breast milk for the first six months.
However, researchers at the University of Cambridge said the impact on the mother was not as clearly understood.
One in 10 women will develop depression after the birth of their child.
The researchers analysed data from 13,998 births in the south-west of England.
It showed that, out of women who were planning to breastfeed, there was a 50% reduction in the risk of post-natal depression if they started breastfeeding.
But the risk of depression more than doubled among women who wanted to, but were not able to, breastfeed.
Dr Maria Iacovou, one of the researchers, told the BBC: "Breastfeeding does appear to have a protective effect, but there's the other side of the coin as well.
"Those who wanted to and didn't end up breastfeeding had the highest risk of all the groups."
The benefit increased for each week of breastfeeding up to one month.
However, any longer term impact on post-natal depression could not be determined due to the small number of women in the study who were still breast feeding several months after the birth.
Dr Iacovou said the health profession needed to pay attention.
She added: "It is right to tell mothers it's right to breastfeed, there's so many benefits, but the thing we need to rethink is giving more support to those who did want to breastfeed and to recognise those who are unable to, are at substantially elevated risk and to make sure health visitors keep an eye on these women."
Possible explanations for the beneficial effect include the release of feel-good hormones when milk is produced.
Dr Iacovou added that social or psychological factors such as feelings of "failing as a mother" were also contributing.
She says the improving the health of the mother will also help the baby.
Rosemary Dodds, a senior policy adviser at parenting charity NCT, said: "Mothers often experience pressures after the birth such as pain, shortage of sleep and anxiety.
"Breastfeeding can help to relax mothers and reduce stress, so it might play a part in preventing mental health issues developing.
"We welcome further research into this subject as perinatal mental health is a huge issue for many mothers. At least one in ten suffer with postnatal depression."