SANTA FE, N.M. — New Mexico Gov. Michelle Lujan Grisham signed a red-flag gun bill Tuesday that will allow state district courts to order the temporary surrender of firearms, and she urged sheriffs to resign if they still refuse to enforce it.

Flanked by advocates for stricter gun control and supportive law enforcement officials at a signing ceremony, Lujan Grisham said the legislation provides law enforcement authorities with an urgently needed tool to deter deadly violence by taking firearms from people who pose a threat to themselves or others.

Some sheriffs from mostly rural areas opposed the bill in committee hearings as a violation of constitutional guarantees to due process, free speech and the right to bear arms. Public rallies were held for and against the legislation.

Lujan Grisham said sheriffs should have the opportunity to oppose any recommended policy change, but “they cannot not enforce.”

“”If they really intend to do that, they should resign as a law enforcement officer and leader in that community,” she said.

New Mexico Sheriffs’ Association President Tony Mace of Cibola County said the new law goes too far by potentially impounding guns before any crime is committed and that he and other sheriffs will assert their discretion over its enforcement.

“We don’t work for the governor, we don’t work for the Legislature,” he said. “We work for the people that elected us into office.”

The legislation allows police and sheriffs deputies to petition a court for the surrender of household firearms within 48 hours from people who appear to pose a danger to themselves or others.

Petitions can be based on sworn affidavits filed by relatives, employers or school administrators, and authorities can be held liable for officers who fail to enforce the law.

The gun-control advocacy group Moms Demand Action is planning a yearslong campaign to publicize the law and outline how people can petition law enforcement for extreme risk protection orders, said Emelie DeAngelis, a state chapter leader.

She said her group is emphasizing that district attorneys can seek red-flag orders from judges in areas where sheriffs may show reluctance.

“We were really adamant that particularly with our sheriffs’ situation — a lot of them saying that they don’t want to enforce this — that the DAs had to stay in” the law, she said.

Lujan Grisham outlined her motivation for signing the red-flag law by invoking the 2019 mass shooting in El Paso, Texas, and the 2018 mass shooting that killed 17 students at a Florida high school.

Red-flag laws gained momentum after it was learned that the young man accused in the Florida attack was widely known to be mentally troubled yet had access to weapons.

“Now this state is responding,” Lujan Grisham said. “We’re looking at the opportunity to do as much as we can for threats that could create mass violence.”

A red-flag order would set off a 10-day deadline for a court hearing on whether the initial order to surrender firearms is extended for a year. A flagged gun owner can request an extension of up to 30 days for the hearing.

Failure to relinquish firearms as ordered is a misdemeanor that can lead authorities to remove weapons under the bill.

Contact us at editors@time.com.