New Mexico Goveror 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 temporarily removing 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.

Get Breaking News Delivered to Your Inbox

Lujan Grisham said sheriffs should have the opportunity to oppose any proposed 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."

New Mexico lawmakers last year expanded background check requirements to most private gun sales and banned firearms possession for people under permanent protective orders for domestic violence.

Highlighting discontent in rural communities, elected commissioners declared Roosevelt County a "sanctuary" for Second Amendment guarantees on Tuesday, recognizing the right of the local sheriff "not to enforce any unconstitutional firearms law against any citizens." The county of roughly 20,000 residents adjacent to Texas is the latest of at least a dozen New Mexico counties to embrace the sanctuary label.

This year's red-flag 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 De Angelis, 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 .

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. The law takes effect on May 20.