BILLINGS, Mont. (AP) — A judge will hear arguments Thursday in the latest legal wrangling between the state of Montana and the ACLU over efforts to prevent people from changing their sex designation on their birth certificate.

The ACLU of Montana is asking District Court Judge Michael Moses to clarify his April ruling temporarily blocking a 2021 law that required transgender people to undergo surgery and obtain a court order before changing their birth certificate.

The law’s requirement for a “surgical procedure” was unconstitutionally vague because it did not say what kind of surgery was required, Moses said in his April ruling. He told the state to go back to using a previous rule stating that people wanting to change their birth certificate in Montana needed only to provide an affidavit to the state health department.

Since that ruling, however, the state health department issued a new rule banning anyone from changing their sex on their birth certificate unless it was incorrect due to a clerical error. The ACLU argues that new rule violates the previous court order.

The legal dispute comes as conservative lawmakers in numerous states have sought to restrict transgender rights, including with bans on transgender girls competing in girls school sports.

Montana Attorney General Austin Knudsen led a group of 17 state attorneys general who pushed back on Monday against a Biden administration proposal that would solidify protections for transgender and gay students. The attorneys general claimed the proposal would coerce schools to “indoctrinate children” with what they called politically driven “gender identity theories.”

The Biden administration move would reverse a Trump-era policy and declare that discrimination based on gender identity will be treated as a violation of federal law. In announcing the change, Education Secretary Miguel Cardona said it was needed so gay, lesbian and transgender students could learn in schools free from discrimination.

In Montana, the issue of changing a person’s sex designation on their birth certificate has led to a flurry of lawmaking and legal challenges.

A 2017 rule issued by the state health department under former Democratic Gov. Steve Bullock eased the process of changing one’s birth certificate.

But in early 2021, with a Republican in the governor’s office, lawmakers passed Senate Bill 280, which called for repealing the 2017 rule and adding the requirement for a surgical procedure.

That was challenged by transgender plaintiffs represented by the ACLU of Montana, who have said a birth certificate that doesn’t match their gender identity puts them at risk of embarrassment, discrimination, harassment or violence if they are asked to provide their birth certificate.

Moses’ temporary injunction in April said the state should go back to the status quo, which he defined as the rule that existed before Senate Bill 280 passed.

A month after Moses handed down the temporary injunction, the health department enacted a new temporary rule effectively banning birth certificate changes.

The ACLU then asked Moses to clarify his April ruling and to declare the temporary rule invalid.

In the meantime, the temporary rule was adopted permanently last week.

State officials have denied that the new rule preventing changes to birth certificates was adopted in bad faith following the court’s injunction.

Assistant Attorney General Kathleen Smithgall said in court documents that state officials last year had canceled the 2017 rule that allowed birth certificate changes. So when the injunction was put in place, Smithgall wrote, the state had to fill a “regulatory gap” and did so with the emergency rule.

Thursday’s hearing will allow the ACLU and the state to make additional arguments.