RALEIGH, N.C. — A federal judge has declared unconstitutional a North Carolina law banning women from having abortions after the 20th week of pregnancy except in an urgent medical emergency.

The decision Monday by U.S. District Judge William Osteen in Greensboro gave state legislators 60 days before his ruling takes effect to allow them to amend abortion restrictions or appeal his ruling to a higher court.

The U.S. Supreme Court has protected abortion as a constitutional right until a fetus has developed enough to live outside the mother's womb. The judge noted that North Carolina's own medical expert conceded that's almost never possible until the 22nd week of gestation.

The law was challenged in 2016 shortly after lawmakers narrowed abortions after the 20th week of gestation so that they were only allowable if the mother faces a risk of death or serious and irreversible harm from some urgent medical emergency.

The 2016 changes also "imposed substantial reporting obligations on abortion providers for any abortion performed after sixteen weeks, expanded the universe of medical facilities from which information is collected, restricted the type of doctor who may perform an abortion in the state, and lengthened the informed consent waiting period from 24 to 72 hours," Osteen wrote in his ruling.

The revised law also meant that abortions were no longer allowed for medical conditions that cause gradual health damage but never reached a specific point to make them immediately necessary, Osteen said.

Pro-life activists Gina Fazenbaker (3rd L) of Clarion, Pennsylvania, and Patrick Elms (2nd L) of Raleigh, North Carolina, discuss the abortion issue with pro-choice activists and local residents Polly Stamatopoulos, from left, and Lisa King, from right, in front of the U.S. Supreme Court after the annual March for Life in Washington on January 24, 2011. Alex Wong / Getty Images file

While North Carolina has not prosecuted anyone for an illegal abortion for more than 40 years, that could change in the future, Osteen said. He wrote that the state's "strident defense" of the lawsuit as well as a wave of similarly worded laws in Wisconsin, Iowa, Arkansas and other states suggests officials haven't disavowed future prosecutions under the 20-week ban.

Some states have gone further this month. Mississippi and Kentucky outlawed most abortions once a fetal heartbeat is detected, which can be as early as six weeks into pregnancy. A similar bill passed the Georgia Senate last week and now goes back to the House to approve changes. It is backed by Georgia's Republican Gov. Brian Kemp.

The North Carolina lawsuit was one of three filed weeks after President Donald Trump's election challenging laws abortion-supporters viewed as unconstitutional restrictions. Laws in Missouri and Alaska were also challenged at the same time by the American Civil Liberties Union, Planned Parenthood and the Center for Reproductive Rights.

The Alaska lawsuit was dropped after the state medical board adopted new regulations for abortions after the first trimester. In Missouri, one of the state's two abortion clinics closed in October after federal appeals court judges ruled that the state could enforce a requirement that doctors must have admitting privileges at nearby hospitals before they can perform abortions.

North Carolina's top Republican legislative leaders had no immediate reaction to the decision. Spokesmen for Senate leader Phil Berger and House Speaker Tim Moore said they needed more time to review the ruling.

An attorney for the ACLU's North Carolina chapter said Osteen's decision affirmed that people have a constitutional right to make their own decisions about their pregnancy.

"North Carolina's ban was written by politicians to intimidate doctors and interfere in a woman's personal medical decisions." attorney Irena Como said. "Important medical decisions throughout different points of a woman's pregnancy, including whether to have an abortion, must be left to the woman and her doctor - not politicians."