RALEIGH, N.C. (AP) – A federal judge has overruled a North Carolina law banning abortions after the 20th week of pregnancy.

U.S. District Judge William Osteen’s ruling Monday gives state legislators 60 days before the law he declared unconstitutional is voided so that they can amend it or appeal his ruling.

The law was challenged shortly after it passed in 2016. It would have allowed abortions after the 20th week of gestation only if the mother faces a risk of death or serious and irreversible harm from some urgent medical emergency.

The U.S. Supreme Court has protected abortion as a constitutional right until a fetus is developed enough to live outside the mother’s womb.

The judge noted that the Legislature’s own medical expert conceded that’s almost never possible until 22 weeks gestation.