By Julie Moreau

In the first statewide referendum on transgender rights, Massachusetts voters on Tuesday said “yes” to maintaining a 2016 law that extended nondiscrimination protections to transgender people, including their use of public bathrooms and locker rooms that align with their gender identity.

With nearly 50 percent of precincts reporting, the “Yes” vote garnered 70 percent of the vote, compared to 30 for the “No” vote. The results are pending official confirmation.

“Massachusetts voters reaffirmed our Commonwealth as a place that fiercely defends our basic values of dignity and respect for everyone,” Carol Rose, executive director of the ACLU of Massachusetts, said in a statement shared with NBC News. “At a time when transgender rights are being threatened nationally, we absolutely must preserve the rights we have secured at the state level.”

The outcome in Massachusetts was a huge relief to LGBTQ-rights activists across the country, who feared that a vote to repeal the 2016 law would prompt a wave of similar efforts to roll back protections in other states. Already, some protections at the federal level are under threat from President Donald Trump's administration.

“Voters in Massachusetts made history tonight and sent a clear message that transgender rights are human rights,” Sarah Kate Ellis, president and CEO of national LGBTQ advocacy group GLAAD, said in a statement. “This victory for transgender people all around the country is the latest sign that the Trump Administration’s attempts to discriminate against transgender Americans are completely out of step with where the American public is.”

Opponents of the 2016 nondiscrimination law have been trying to repeal it since its passage. The group Keep MA Safe said the law enables people with “evil intentions” to “prey on the vulnerable.”

“We are deeply disappointed that the people of Massachusetts will continue to be forced to sacrifice their privacy and safety in the name of political correctness,” Andrew Beckwith of Keep MA Safe said. “Our commitment to defending the fundamental rights to privacy and safety, particularly for women and children, will not change. We will move forward, developing other strategies to protect the rights of those who are negatively affected by this law.”

The ballot measure attracted the attention of celebrities and transgender advocates across the U.S., who used the hashtag #YesOn3 to show their support for the anti-discrimination measure.

According to data collected by the Movement Advancement Project, an LGBTQ think tank, Massachusetts is one of only 19 states and some 250 municipalities with transgender nondiscrimination protections in public accommodations.

North Carolina remains the only state to have successfully passed (and then subsequently repealed) legislation that restricted transgender people’s usage of sex-segregated public facilities, according to the National Conference of State Legislatures. At least 19 other states have considered such legislation since 2016.

In April, voters in Anchorage, Alaska, defeated a similar initiative to the one on the Massachusetts ballot, and similar measures in Washington and Montana recently failed to make it onto the ballot.

Reg Calcagno, an ACLU state advocacy strategist who had been working on Massachusetts’ Yes on 3 campaign, said the results of the ballot initiative “sends a clear message that transgender people will not be erased.”

“When we introduce folks to the trans community … and have a conversation about our respect and dignity, we win,” Calcagno, who identifies as gender non-binary and uses they/them pronouns, explained. “I think about how much we can accomplish when we have those conversations.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM

Associated Press contributed.