Happiness and contentment are catching, but depression is not, research has shown.
Scientists studied the way mood was transmitted through a population of more than 2,000 US high school students using methods normally employed to track infectious diseases.
They found that while depression did not "spread", having enough friends with a "healthy" mood halved the chances of becoming depressed over a six to 12-month period.
For those already depressed, being around positive people doubled the likelihood that they would recover.
Dr Thomas House, one of the researchers from the University of Manchester, said: "We know social factors, for example living alone or having experienced abuse in childhood, influence whether someone becomes depressed. We also know that social support is important for recovery from depression, for example having people to talk to.
"Our study is slightly different as it looks at the effect of being friends with people on whether you are likely to develop or recover from being depressed.
"This was a big effect that we have seen here. It could be that having a stronger social network is an effective way to treat depression. More work needs to be done but it may be that we could significantly reduce the burden of depression through cheap, low-risk social interventions."
While being with people who were depressed presented no risk, having happy and contented friends was both protective and curative, said the scientists.
The findings are published in the journal Proceedings of the Royal Society B.
Dr House said: "As a society, if we enable friendships to develop among adolescents (for example providing youth clubs) each adolescent is more likely to have enough friends with healthy mood to have a protective effect. This would reduce the prevalence of depression."
Co-author Edward Hill, an applied mathematician from the University of Warwick, said: "We've ensured that the method we used was not confounded by homophily - that's the tendency for people to be friends with others like themselves. This would have affected our research.
"For example, if many adolescents drink a lot of alcohol and their friends drink a lot too, it may be that alcoholic drink causes depression among the young people rather than who they are friends with."