An Alabama bill intended to test whether President Trump’s Supreme Court appointees will allow for the banning of abortion, even in cases of rape and incest, threatened Wednesday to reshape the dynamics of the 2020 election.

Democrats erupted with loud and sustained outrage in an effort to reclaim the upper hand on a politically sensitive issue that has recently found them on the defensive after liberal states proposed extending protections for abortions late in pregnancy.

Republicans leaders, by contrast, spent much of the day avoiding questions about the Alabama law, wary of being dragged into a debate over whether to refuse rape and incest victims the option of abortion following forced pregnancies.

Trump left the topic of the Alabama law unaddressed on Twitter, the White House offered no comment about the measure, and several Republican senators such as Martha McSally (Ariz.) and Thom Tillis (N.C.), who are facing tough reelection fights, avoided the issue as best they could.

“That’s a state issue. I’m focused on my work here,” McSally said in a hallway interview at the U.S. Capitol.

Tillis dodged in a similar encounter: “I’m going to leave it to the folks in Alabama how to govern that state.”

Alabama’s Republican Gov. Kay Ivey on Wednesday evening signed the abortion measure, which is the most restrictive abortion law in the nation. Approved by the state legislature Tuesday night, it provides criminal penalties for any doctor who performs an abortion, unless it is necessary to save the life of the mother. Doctors could be imprisoned for up to 99 years.

Her signature, which had been expected, came after a day in which several of those who have long opposed abortion rights made clear they considered the nature of the Alabama measure politically dangerous for Republicans. In past years, even the strongest antiabortion measures had created loopholes for women and girls pregnant due to rape or incest.

Pat Robertson, an antiabortion evangelical pastor who ran for president as a Republican in 1988 , offered caution by calling the Alabama law “extreme” and saying that he thought it would lose if taken to the Supreme Court in an effort to overturn Roe v. Wade, the 1973 decision that legalized abortion nationwide.

“If they can make our pro-life position about the Alabama bill, rather than our opposition to late-term abortion and infanticide, which they have been supporting, then we are going to be on the defense,” said Ralph Reed, the chairman of the socially conservative Faith and Freedom Coalition, who supports the Alabama bill. “I tend to think that’s not going to happen.”

The bill was the latest in a wave of efforts by antiabortion activists to create legislation that would give the Supreme Court, which has grown more conservative under Trump, the opportunity to once again allow states to outlaw abortions in most cases. The governors of Ohio and Georgia also have recently signed bills that outlaw abortion after a fetal heartbeat is detected — at about six weeks following conception, before many know they are pregnant.

Democratic strategists argue that the Alabama law will help put the threat to Roe v. Wade more squarely on the agenda in the 2020 election, as a possible rallying point for women and highly educated voters. Suburban women had been a particular target for Democrats even before the abortion measures surfaced.

Democrats already have been planning to attack vulnerable Republican senators, including Maine’s Susan Collins and Colorado’s Cory Gardner, who voted for Justice Brett M. Kavanaugh, a potential swing vote on the Supreme Court for any case that reconsiders abortion law.

“The Alabama law, and others like it, clearly identify the Republicans as the extreme party on the issue of abortion, even as Republicans try to attack Democrats as being too far left on the issue,” Geoff Garin, a Democratic pollster, said in an email. “Radical laws like the one in Alabama will keep Republicans on the defensive in terms of being outside the mainstream.”

Democratic presidential candidates echoed a similar refrain. “We will not stand for it,” thundered Sen. Kamala D. Harris (Calif.) during a New Hampshire rally. Sen. Elizabeth Warren (Mass.) called the bill “exceptionally cruel,” while former Texas representative Beto O’Rourke called it “a radical attack on women,” and Washington Gov. Jay Inslee called the measure “an abomination.”

Harris, O’Rourke and Mayor Pete Buttigieg of South Bend, Ind., also emailed their campaign lists Wednesday to raise money for abortion rights groups.

“Rolling back the clock on basic women’s human rights and civil rights, I think, has to be fought with every tooth and nail,” said Sen. Kirsten Gillibrand of New York, another presidential candidate. “This is a fight that women cannot lose.”

Even Alabama’s senior senator distanced himself from Republicans in the state legislature.

“I have supported consistently the Hyde Amendment, which is the federal law,” said Sen. Richard C. Shelby, when asked about his state’s bill. The Hyde Amendment bars the use of federal funds for abortion except in cases of rape and incest — the circumstances omitted from the legislation — or to save the life of the mother.

Until recently, Republicans have been on offense on the issue of abortion, deploying a similar playbook to the one Democrats are now using by calling their opponents extreme due to a recent law passed in New York that expanded access to abortions late in a pregnancy.

In his State of the Union address this year, Trump pointed to the New York law and comments by Virginia Gov. Ralph Northam (D) about a proposed abortion bill to argue that Democrats supported efforts to “allow a baby to be ripped from the mother’s womb moments before birth” or allow for a doctor to “execute a baby after birth.” (Northam did not say he supported execution of a baby after birth.)

During his short political career, Trump has been successful in using abortion to solidify his support among evangelical voters initially skeptical of him. Though he had described himself as an abortion rights advocate for much of his life, he was the first Republican nominee to openly promise to appoint antiabortion justices to the Supreme Court. He said during the 2016 campaign that his appointees would overturn Roe “automatically” if he were elected.

Since then, the connection between Trump and evangelicals has only deepened, according to polls. Evangelicals have been among the most loyal Trump supporters, and White House advisers have taken to praising him as the nation’s “most pro-life” president. As he has pursued reelection, Trump has made the topic part of his campaign pitch.

“Democrats are aggressively pushing late-term abortion, allowing children to be ripped from their mother’s womb right up until the moment of birth,” Trump said last week during a rally in Florida. “To protect innocent life, I called on Congress to immediately pass legislation prohibiting extreme late-term abortion.”

But on Wednesday, Trump did not mention the new legislation in Alabama, Georgia and Ohio that would significantly restrict abortion access. The Trump reelection campaign referred questions about the Alabama bill to the White House, which declined to comment on the bills specifically, leaving little doubt about where they would prefer to fight over abortion in the coming months.

“Unlike radical Democrats who have cheered legislation allowing a baby to be ripped from the mother’s womb moments from birth, President Trump is protecting our most innocent and vulnerable,” said White House spokesman Judd Deere.

American views on abortion have changed little over the last 20 years, with 58 percent saying the procedure should be legal in all or most cases in 2018, compared to 60 percent in 1995, according to the Pew Research Center. Self-identified Democrats, liberals and those with college degrees are more supportive of legal access to the procedure.

But the political impact of abortion tends to be most pronounced when the focus is on how to handle more extreme cases, as a majority of voters take a non-absolutist position on regulating it, supporting some limits but opposing outright bans.

Republicans lost two key Senate elections in 2012 after their candidates, Todd Akin in Missouri and Richard Mourdock in Indiana, made comments about pregnancies that resulted from rape. Akin said falsely that women’s bodies could shut down pregnancies that resulted from “legitimate rape,” and Mourdock said he believed “God intended” pregnancies that resulted from rape.

Twenty years earlier, Democrats also benefited when — after court decisions limiting abortion and the confirmation fight of Justice Clarence Thomas, accused of sexual harassment — a wave of women helped push their candidates to victory in 1992.

After that election, the antiabortion pollster Kellyanne Conway, who is now a top White House adviser to Trump, gave briefings to Republican lawmakers imploring them to treat “rape” as a “four-letter word” and stop talking about it in the context of the abortion debate.

“Both sides are playing to the narrow slice of voters who passionately agree with their extreme positions, and they hope that voters who are closer to the center on abortion will make their voting decision based on other issues,” said Whit Ayres , a Republican pollster. “It obviously heightens polarization and does nothing to help resolve the issue where most Americans are.”

Emily Wax-Thibodeaux, Paul Kane, Mike DeBonis and Toluse Olorunnipa contributed to this report.