DES MOINES, Iowa — Abortion-rights groups said Tuesday that they had filed a lawsuit challenging the nation’s most restrictive abortion law, an Iowa provision that bans most abortions once a fetal heartbeat is detected, around the sixth week of pregnancy.

Almost immediately, the state’s attorney general said he would not defend the law. Democrat Tom Miller said he based his decision on a belief that the measure “would undermine rights and protections for women.”

The lawsuit filed by the American Civil Liberties Union and the Planned Parenthood Federation of America seeks an injunction that would put the law’s July 1 implementation on hold during the lawsuit, a legal process that could take years. An Iowa City clinic is also a plaintiff.

“We’ve moved quickly to challenge this cruel and reckless law because it cannot be allowed to take effect,” Rita Bettis, legal director for the ACLU of Iowa, told a news conference.

The lawsuit names Gov. Kim Reynolds and the Iowa Board of Medicine as defendants, Bettis said.

Reynolds, who signed Iowa’s ban earlier this month, said at a public event in Davenport that she felt “very confident in moving forward with it.”

Republicans want any legal challenge to reach the U.S. Supreme Court in hopes of overturning the 1973 Roe v. Wade ruling.

The law is the latest to test the legality of abortion restrictions. GOP lawmakers in Mississippi earlier this year passed a 15-week abortion ban. It was signed by Mississippi’s Republican governor and quickly put on hold after a court challenge.

The law is evidence of the state’s conservative shift after the 2016 election, when Republicans gained control of the Legislature and the governor’s office for the first time in nearly 20 years. Last year, they approved a 20-week abortion ban and required women to wait three days before they could have an abortion. The waiting provision is on hold because of a separate lawsuit filed by Planned Parenthood and the ACLU.

Iowa Republicans last year also gave up millions in federal dollars to create a state-funded family planning program that prohibits participation from abortion providers such as Planned Parenthood.

Associated Press Writer Ryan Foley in Davenport contributed to this report.