Tennessee’s felony law aimed at local “sanctuary” immigration policies has been struck down after the state declined to defend the provision in court, leaving a dispute over legislative voting immunity resolved through an agreed order signed in Nashville.

The agreed order was signed Wednesday by Nashville Chancellor Russell Perkins, according to the terms of the settlement involving the Tennessee attorney general’s office, the local district attorney and seven Nashville-Davidson County metro council members who are plaintiffs in a lawsuit challenging the policy, the Associated Press reported. The lawsuit questioned whether the state could threaten elected officials with criminal penalties for taking positions on immigration-related local policies.

For months, Attorney General Jonathan Skrmetti’s office said it would not defend the provision, the AP said. Skrmetti, a Republican, told reporters in September that the Constitution gives “absolute immunity for all legislative votes, whether at the federal, state, or local levels,” a position he advanced even as Tennessee has banned sanctuary cities and counties from 2019, the AP reported.

Metro Council member Clay Capp said in a news release that the outcome allows elected officials to represent residents without facing criminal risk. “This settlement affirms a basic American principle: the government cannot prosecute you for how you vote,” Capp said in a statement carried by the ACLU of Tennessee release; the ACLU of Tennessee also said Tennessee tried to “gag local officials with threats of prison time,” but that the Constitution does not allow it, according to the AP account.

The challenged provision was approved earlier last year by a GOP-supermajority Legislature and Republican Gov. Bill Lee, the AP said. The law’s penalty framework included the possibility of a Class E felony—punishable by up to six years in prison—for any local elected official who votes for or adopts a “sanctuary policy” as defined under Tennessee law, which the AP said could cover local government restrictions that impede federal immigration enforcement efforts to detain migrants without permission.

Legislative counsel warnings about potential unconstitutionality accompanied the measure, the AP reported, but Republican lawmakers kept the provision in a broader immigration bill. The AP also reported that legislative GOP leaders defended the penalty, including House Majority Leader William Lamberth, who called it “the easiest felony in the world to avoid.”

The case leaves in place the question of what state lawmakers may do when they disagree with local approaches to immigration enforcement, but it resolves the Nashville dispute on the basis of the immunity argument advanced by Skrmetti’s office and accepted in the agreed order signed by Perkins.