Iowa’s “fetal heartbeat” law, the most restrictive abortion ban in the United States, was declared unconstitutional Tuesday, as it violates the Iowa state constitution, a state judge ruled.

Iowa’s Republican-controlled legislature passed the restriction in May 2018, outlawing the procedure after a fetal heartbeat is detected, often at six weeks and before a woman realizes she is pregnant.

In the ruling, posted online, District Court Judge Michael Huppert wrote, “It is undisputed that such cardiac activity is detectable well in advance of the fetus becoming viable.”

A fetus that is viable outside the womb, usually at 24 weeks, is widely considered the threshold in the United States to prohibit an abortion.

The district court decision is a victory for supporters of abortion rights, but abortion opponents have vowed to take the fight to Iowa’s appellate courts, the Des Moines Register and other media reported.

The legislation is aimed at triggering a challenge to Roe v. Wade, the U.S. Supreme Court’s 1973 landmark decision which established that women have a constitutional right to an abortion, activists on both sides of the issue previously told Reuters.

AP Photo/Charlie Neibergall Protesters rally outside Iowa Gov. Kim Reynolds' office, on May 4, 2018, at the Statehouse in Des Moines.

Iowa state Sen. Janet Petersen of Des Moines, the Democrats’ leader in the Iowa Senate, praised the ruling.

“The extreme law should have been overturned, because it restricted the freedom of Iowa women and girls to care for their bodies, and it forced motherhood on them,” she told the Register. “The governor and legislative Republicans should stop attacking women’s health care.”

Proponents of the law had expected a long court fight.

The ultimate goal, abortion opponents have told multiple media outlets, is to get the case before the U.S. Supreme Court, which has become more conservative under President Donald Trump.

When the Iowa law was first passed, Republican state senator Rick Bertand of Sioux City told Reuters, “We created an opportunity to take a run at Roe v. Wade - 100 percent.”

(Editing by Nick Macfie)