American opinions about same-sex marriage are catching up with LGBTQ rights.

Anti-gay bias has declined significantly in many areas of the US, a new study appearing this week in Proceedings of the National Academy of Sciences (PNAS) finds. And it all hinges on legalized nuptials, according to the research conducted by McGill University’s Department of Psychology, where they’re studying America’s changing attitudes towards homosexuality.

“The idea that norms shape attitudes has been around in social psychology for many years,” says senior author and McGill psychology professor Eric Hehman. “We wanted to measure if laws and policies can also act as norms and potentially change deeply rooted biases.”

Using Harvard-backed website Project Implicit, which tracks volunteer responses to analyze implicit biases and assumptions, Hehman’s team was able to collect opinions from more than 1 million users during a 12-year period, noting changes in trends before and after gay marriage legislation.

Before the Supreme Court ruled in 2015 to allow same-sex marriage across the country, 35 other states plus Washington, DC, had already done so locally, starting with Massachusetts in 2004. Overall, polls suggest that support for same-sex marriage has steadily climbed, researchers say.

While bias against the gay community is in decline overall, they found that states which had passed laws allowing for same-sex marriage saw their anti-gay bias decline at double the rate.

However, the states which had not passed same-sex marriage legalization on their own volition saw an immediate uptick in anti-gay bias following the federal mandate. Hehman calls this the “backlash effect,” suggesting that already shifting attitudes in favor of same-sex marriage had not yet reached a critical mass in those states.

He says these results also indicate that constituency attitudes may have help force the hand of local politicians, which in turn encouraged others to adopt more liberal ideals.

“In other words, representative governments can contribute to and/or intensify change in the attitude of citizens by passing legislation,” Hehman says. “We have some evidence that the laws caused this changed in bias, but it is possible the effect goes in both directions.”