The Alabama Senate Tuesday passed a bill criminalizing abortion in nearly all cases, approving the most sweeping restrictions on the procedure in the United States and almost certainly guaranteeing a legal challenge if signed by Gov. Kay Ivey.

The measure passed the Senate 25 to 6 after more than four hours of often emotional debate that at one point led to the introduction of spectators who had abortions after being raped. The chamber rejected putting exceptions in for rape and incest on a 21 to 11 vote. The bill now goes to Ivey, who has not indicated her feelings on the bill.

Sponsored by Rep. Terri Collins, R-Decatur, the bill would make it a Class A felony – punishable by life or 10 to 99 years in prison – for a doctor to perform an abortion in the state of Alabama. Attempting to perform an abortion would be a Class C felony, punishable by one to 10 years in prison.

The legislation was drafted by Eric Johnston of the Alabama Pro-Life Coalition and framed as an explicit attempt to challenge Roe v. Wade, the 1973 U.S. Supreme Court decision that struck down state bans on abortion in the first trimester of pregnancy.

Alabama abortion vote:Here's what to know about the state's proposed abortion bill

Protests begin:'Get out of my uterus': Abortion rights advocates protest Alabama ban

The bill, if it becomes law, would only allow abortions if the life of the mother was threatened; if the woman had a mental illness that could result in the death of her or her child, or if the fetus had a fatal anomaly that would result in stillbirth or its death after birth.

"This decision could have an impact on our state as well as our nation," said Sen. Clyde Chambliss, R-Prattville, who handled the bill in the Senate. "It could have an impact on millions of as yet unborn children."

Collins’ bill would not allow abortion in the case of sexual assault. The bill’s supporters argue that allowing such exceptions would dilute the bill’s argument for the personhood of the fetus. Collins said in a press conference after the bill passed that she intended the bill to be a challenge to Roe v. Wade, and that she would expect the legislature to return to the issue if the Supreme Court reversed itself on the issue.

Collins sponsored bills in the past that would have banned abortion at the detection of a fetal heartbeat, and said she would support abortion in cases of rape and incest in a post-Roe world.

"I have prayed my way through this issue and this bill, because it was hard to give up heartbeat," she said. "I believe we can’t get a heartbeat bill until we get Roe v. Wade turned over."

ACLU Alabama, Democrats respond to abortion bill

Collins said she would support abortion rights in cases of rape and incest, but Chambliss and Rep. Rich Wingo, R-Tuscaloosa, who flanked Collins at a press conference. All three voted to reject rape and incest exceptions in the current bill.

But it's not clear whether a future legislature would want to revisit the issue, or how much rooms they would have in doing so. Last fall, state voters approved a state amendment that said there was no right to an abortion embedded in the Alabama Constitution.

Abortion rights groups denounced the bill as an attack on women’s access to health care, and have promised to fight the measure.

More:Strict state anti-abortion laws aimed at Supreme Court; justices not eager to consider them

More:Trump fact check: Babies executed after failed abortions. He's oversimplifying, AP finds

"The ACLU of Alabama, along with the National ACLU and Planned Parenthood, will file Stories a lawsuit to stop this unconstitutional ban and protect every woman’s right to make her own choice about her healthcare, her body, and her future," the ACLU of Alabama wrote in a statement on Tuesday. "This bill will not take effect anytime in the near future, and abortion will remain a safe, legal medical procedure at all clinics in Alabama.”

Staci Fox, the president and CEO of Planned Parenthood Southeast, said in a statement that the politicians who voted for the bill "will forever live in infamy for this vote and we will make sure that every woman knows who to hold accountable."

"In the coming days we will be mounting the fight of our lives -- we will take this to court and ensure abortion remains safe and legal," Fox said in the statement. "For now, our doors are open for the many patients who need access to care.”

Senate Majority Leader Greg Reed, R-Jasper, said in a statement that the bill "simply recognizes that an unborn baby is a child who deserves protection," and added "despite the best efforts of abortion proponents, this bill will become law because Alabamians stand firmly on the side of life.”

Democrats sharply criticized the bill as unconstitutional and forcing victims of sexual assault to have their attackers' children. During the debate, Senate Minority Leader Bobby Singleton, D-Greensboro, introduced three women in the Senate gallery who had abortions after sexual assault.

"If you are going to allow a baby to be raped, or a father, or an uncle, or a cousin to have babies by their own family, you couldn't have been thinking this through," he said.

But the body rejected an amendment from Singleton creating exceptions for sexual assault. In the Montgomery delegation, Sen. Will Barfoot, R-Pike Road, voted against the amendment to add rape and incest exceptions to the near-total abortion ban. Sen. David Burkette, D-Birmingham, voted for it.

The rejection led to heated criticism from Singleton.

"You just said to my daughter, 'You don't matter,'" he said. "'You don't matter in the state of Alabama' ... I got to go home and tell her, 'the state of Alabama doesn't care about you, baby.'"

All seven Democrats in the chamber voted for the exceptions for rape and incest. Republican Senate President Pro Tem Del Marsh and Republican Sens. Andrew Jones of Centre; Jim McClendon of Springville and Cam Ward of Alabaster also voted for the exceptions. All 21 no votes came from Republicans.

Sen. Vivian Davis Figures, D-Mobile, one of four women elected to serve in the 35-member chamber, introduced an amendment that would have criminalized vasectomies. The amendment was defeated 21 to 5.

"You do not have to raise that child," she said. "You do not have to carry that child. You do not have to do anything for that child. But you want to make that decision for that woman for what she should do."

Democrats also criticized supporters of the bill for what they said was a lack of care for children after birth.

"The sin to me is bringing a child into this world and not taking care of them," said Sen. Linda Coleman-Madison, D-Birmingham. "The sin for me is that this state does not provide proper care and proper education."

The measure passed the House overwhelmingly on April 30, after Democrats walked out of the chamber in protest. Earlier that day, House Republicans overwhelmingly voted down a measure that would have added rape and incest exceptions to the bill. But some Senate Republicans expressed reservations about a bill without exceptions for rape and incest.

Republicans in a Senate committee on May 8 added an amendment that included rape and incest provisions in the bill. But the following day, Lt. Gov. Will Ainsworth quickly tabled the amendment as Democrats moved for a roll call on the amendment.

The move, which came too quick for any legislator to register a protest, led to an angry exchange between Ainsworth and Senate Minority Leader Bobby Singleton, D-Greensboro, who had made it clear he wanted to debate the measure. The body adjourned after some Republicans suggested they would talk on the bill.

If signed by Gov. Kay Ivey, the ban would take effect six months after signature. Even if Ivey were to veto the measure, her rejection could be overridden by simple majorities in both chambers. The 105-member House passed the bill 74 to 3 on April 30.