The hallucinogen found in "magic mushrooms" may help ease the pain of feeling rejected or left out of a group, a small new study suggests.

In the study, 21 healthy people were given a small dose of psilocybin, a hallucinogenic compound found in certain mushroom species. They then had their brains scanned while they played an online game in which they were made to feel socially excluded.

During this game, people reported feeling less social pain when they received psilocybin, compared with when they received a placebo, or "dummy pill." In addition, participants' brain scans showed less activity in brain regions linked with feelings of social pain after they took psilocybin compared with after taking a placebo.

The new findings may help scientists better understand exactly what happens in the brain when people feel socially rejected, and potentially develop treatments to reduce these negative feelings, the researchers said. Such treatments could be important for people with certain psychiatric disorders, who often encounter social rejection, and who may react more strongly to rejection than a healthy person, which can worsen mental health, the researchers said.

"Social ties have repeatedly been shown to be crucial for physical and mental health," the researchers, from the University of Zurich in Switzerland, wrote in their findings published April 18 in the journal Proceedings of the National Academy of Sciences. "Understanding the neural and biochemical foundations of rejection experiences is important for increasing our knowledge about social and emotional processes, and is crucial for the treatment of conditions influenced by social factors," they said. [11 Odd Facts About 'Magic' Mushrooms]

Psilocybin may work to reduce feelings of social rejection by stimulating brain receptors for serotonin, a brain chemical thought to be involved in regulating mood. The new findings suggest that these brain receptors may be important for processing social situations as well as feelings of social rejection, the researchers said.

In addition, people in the study who took psilocybin reported feeling more connected to, or "at one" with their environment. This finding suggests that the drug may reduce people's feelings of self-centeredness, and "consequently render negative experiences more bearable," the researchers said.

It's important to note that the new study involved only healthy people, and it's not clear whether the findings would translate to patients with psychiatric conditions.

Psilocybin is an illegal drug, but it is being considered as a treatment for terminally ill patients who experience depression and anxiety. The drug can have side effects, including paranoia and delusions, but studies have found that when people are given low doses of the drug in a controlled environment, such as a laboratory, most people do not experience harmful effects.

Copyright 2016 LiveScience, a Purch company. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.