North Dakota's law banning abortions after six weeks of pregnancy is unconstitutional, a federal judge ruled Wednesday, striking down what critics had called the nation's most extreme limit on the procedure.

The law, which was approved last year but never took effect, made it a crime for a woman to abort a fetus with a detectable heartbeat. Offending doctors faced up to five years in prison. An exception was allowed for medical emergencies.

U.S. District Judge Daniel Hovland said the law was "in direct contradiction" to the Supreme Court's 40-year-old decision in Roe v. Wade, which established "viability" as the critical point at which states could begin restricting abortions. North Dakota and several other states already ban abortions when a fetus is considered viable, typically around four months.

"The United States Supreme Court has spoken and has unequivocally said no state may deprive a woman of the choice to terminate her pregnancy at a point prior to viability," Hovland wrote.

He said that while the "emotionally fraught" controversy over a woman's right to choose would continue, courts are obligated to uphold the existing precedent until the U.S. Supreme Court weighs in again.

An Arizona measure that sought to ban abortions starting at 20 weeks and an Arkansas ban on abortions after about 12 weeks were also struck down recently by federal judges. The Arkansas and North Dakota measures were the strictest measures passed in 2013, the National Women's Law Center said.

The challenge to the North Dakota law was brought by the state's only abortion clinic, Red River Women's Clinic in Fargo, with the help of the Center for Reproductive Rights in New York City.

In court filings, the state admitted that it was trying to ban all abortions. A physician speaking for the state argued that viability was reached at the point of conception.

Hovland acknowledged that viability was a flexible point to be determined by doctors. Although medical advances mean viability can be earlier than it used to be, he said that he was in no position to accept the state expert's "giant leap."