A federal judge ruled on Monday that an Alabama law requiring abortion providers to have admitting privileges at local hospitals is unconstitutional.

U.S. District Judge Myron Thompson said the new law, which evidence shows would have closed three out of Alabama's five abortion clinics, imposes an "undue burden" on women's ability to seek an abortion.

"A significant number of the women would be prevented from obtaining an abortion; others would be delayed in obtaining abortions, exposing them to greater risks of complications; and even the women who are able to obtain abortions would suffer significant harms in terms of time, financial cost, and invasion of privacy," Thompson wrote in the opinion.

The law also increases the risk that women who could not access legal abortion would take matters into their own hands, Thompson said. One abortion provider "testified that she has already begun to see a few patients a month who had attempted to self-abort using illegally obtained medications, because the medications were less expensive than a supervised abortion," Thompson wrote. "At the worst, there is a danger that women would attempt surgical abortions on themselves."

The admitting privileges law is an increasingly common state-level abortion restriction that requires all abortion providers to be able to practice medicine at a local hospital. Supporters of the law claim that it provides women continuity of care in case they have an emergency, while opponents claim it's a back-door method of shutting down abortion clinics. In Alabama's case, three out of five clinics in the state employ doctors who do not live in Alabama and thus cannot obtain admitting privileges at a local hospital. Those clinics, in Birmingham, Mobile and Montgomery, would not be able to continue operating if the law was enforced.

Thompson said the state's argument that the admitting privilege requirement protects women's health is "exceedingly weak."

"In light of the safety of abortions, the rarity of serious complications, and the robust regulation and oversight of clinics in Alabama, the court is firmly convinced that the Birmingham, Mobile, and Montgomery clinics currently have strong complication-care policies in place and, when complications have arisen, they provided quality care to their patients," he wrote.

The judge concluded his 172-page decision by comparing abortion rights to gun rights in Alabama.

"Suppose, for the public weal, the federal or state government were to implement a new restriction on who may sell firearms and ammunition and on the procedure they must employ in selling such goods and that, further, only two vendors in the State of Alabama were capable of complying with the restriction: one in Huntsville and one in Tuscaloosa," Thompson wrote, referring to the locations of the two abortion clinics that would have been able to stay open. "The defenders of this law would be called upon to do a heck of a lot of explaining -- and rightly so in the face of an effect so severe."

The American Civil Liberties Union, which brought the lawsuit against the abortion restriction, celebrated the ruling on Monday.