Living in a community that recognizes gay marriage can improve the mental health of all teens, according to a new study.

State marriage equality laws enacted in the years before the 2015 Supreme Court ruling were linked to lower rates of suicide attempts among all high school students but especially among teens who identified as gay, lesbian, bisexual or unsure. Ultimately, the researchers found, for every year that same-sex marriage laws were in place, 134,000 fewer teens attempted suicide.

This is noteworthy because queer teens are more than four times as likely to attempt suicide as their straight peers.

While the study doesn’t demonstrate that these laws actually caused a reduction in suicide attempts, lead study author Julia Raifman theorized that having equal protection under the law may account for much of the change.

“These are high school students so they aren’t getting married any time soon, for the most part,” said Raifman, a post-doctoral fellow at the Johns Hopkins University Bloomberg School of Public Health, in a statement about her research.

“Still, permitting same-sex marriage reduces structural stigma associated with sexual orientation. There may be something about having equal rights ― even if they have no immediate plans to take advantage of them ― that makes students feel less stigmatized and more hopeful for the future.”

Raifman’s theory is an important measure in this new political climate. Same-sex marriage is now federal law, thanks to the 2015 Supreme Court case Obergefell v. Hodges, but there are worrying signs that Republican politicians may start to undermine the right to marriage and LGBTG protections in general, both at the state and federal levels.

Studies like this one show that equal marriage rights benefit those who want to marry someone of the same gender but also improve mental health for everyone, especially queer teens.

“Policymakers need to be aware that policies on sexual minority rights can have a real effect on the mental health of adolescents,” she concluded. “The policies at the top can dictate in ways both positive and negative what happens further down.”

The link between equal marriage and teen suicide attempts

Before 2015, only 35 states had legalized same-sex marriage. During this era, Raifman surveyed nearly 800,000 students of all sexual orientations from 1999 to 2015 about suicide attempts both before and after 32 states had legalized same-sex marriage. She also compared teen suicide attempts in states that legalized marriage to those in states that didn’t.

Before the passage of same-sex legislation, nearly 9 percent of all teens and nearly 29 percent of queer-identifying teens had attempted suicide. After states enacted same-sex marriage laws, suicide attempts dropped to 8 percent among all teens and 25 percent among queer teens.

That might not seem like a lot, but based on these reductions, Raifman estimates that every year of same-sex marriage policies was linked to about 134,000 fewer teens attempting suicide.

Alissa Scheller/The Huffington Post In states with same-sex marriage policies the percent of students reporting a suicide attempt in the past year decreased especially among LGBT youth.

How the right to marry affects mental health

Raifman’s study adds to a body of research demonstrating links between same-sex marriage laws and mental health in the queer community. For instance, a 2010 study suggested that psychiatric disorder diagnoses among queer people increased significantly in states that banned same-sex marriage in 2004 and 2005, and that spending on mental health services decreased among gay men in Massachusetts after the state legalized same-sex marriage in 2003, no matter their relationship status.

Laws that speak to the core of a person’s identity can have the effect of making someone feel included in wider society, says Dan Reidenberg, director of Suicide Awareness Voices of Education in Minnesota.

The right to marriage also signals a right to experience love, to be a part of a romantic relationship and the right to a certain social status and benefits. This makes people feel more included and lessens shame about their status as a sexual minority, he said.

Reidenberg wasn’t involved in Raifman’s analysis, but he praised it for emphasizing a reduction in the number of suicide attempts.

“Any time we lessen the potential for death by taking away the number of attempts, we’re literally saving people’s lives.”

“The more that people feel that they are accepted and that people are not going to ostracize them or stigmatize them or put them in a separate category and make them feel different and uncared for, the better off we’re going to be in terms of keeping people alive,” Reidenberg continued. “We’re not just talking about reducing suicide, as you can see in this study, but we’re talking about general mental health and well being.”

On the other hand, laws that bar same-sex couples from legal marriage can have negative psychosocial effects, both on the couples themselves and the children they are raising together. A 2006 article written by members of the American Academy of Pediatrics (and published the same year the anti-LGBT Defense of Marriage Act went into effect) argued for more inclusive public policies for LGBT relationships because of their potential to strengthen family ties between parents and children, and also to protect the children legally, financially and emotionally from the insecurity of an uncertain legal status.

Raifman’s study was published in the journal JAMA Pediatrics.

This reporting is brought to you by HuffPost’s health and science platform, The Scope. Like us on Facebook and Twitter and tell us your story: scopestories@huffingtonpost.com.