Republicans finally won House approval Wednesday for a late-term abortion ban after dropping rape provisions that provoked a rebellion by female GOP lawmakers, forcing party leaders into an embarrassing retreat.

The near party-line 242-184 vote marked a victory for anti-abortion lawmakers and organizations. But the path to passage took months of negotiations among those groups, female lawmakers and party leaders, underscoring how tough it will be for the GOP to satisfy anti-abortion forces while retaining support from women voters for next year's elections.

House Speaker John Boehner, R-Ohio, called the bill "the most pro-life legislation to ever come before this body," adding, "We should all be proud to take this stand today."

Even with House passage, the measure stands little chance of becoming law. Its fate is uncertain in the more moderate Senate and President Barack Obama would likely veto it, leaving it chiefly a way for the GOP to underscore its backing for the anti-abortion goals of some of its most ardent supporters.

White House spokesman Josh Earnest contrasted the measure's strictures with the usual Republican demands for keeping government out of people's lives, saying, "The bill continues to add a harsh burden to survivors of sexual assault, rape and incest who are already enduring unimaginable hardship."

The legislation forbids most abortions starting with the 20th week of pregnancy.

In January, Republican leaders abruptly postponed a vote on the original version, which permitted rape victims to have abortions only if they'd reported the assault to police. The new bill instead requires those women to receive medical care or counseling at least 48 hours before an abortion.

Republican women and moderates objected that the initial bill clamped harsh requirements on women making stressful decisions and could make the GOP seem callous.

"This has a much less punitive substance to it," said Rep. Jackie Walorski, R-Ind., who said she'd now support the legislation. "It's important that when we look at the care of women who are in crisis, that we make sure they're totally taken care of."

The January delay was particularly awkward for GOP leaders because that vote was to occur during the annual March for Life by abortion opponents who flock to Washington for the event. Wednesday's vote came on the second anniversary of the murder conviction of Kermit Gosnell, a Pennsylvania abortion doctor, in the deaths of three babies killed with scissors after delivery.

To help win support from anti-abortion lawmakers, the revamped measure has new protections for unborn babies.

If an abortion doctor believes the fetus could survive outside the womb, a second doctor must be present to care for it, including taking it to a hospital. Women would also have to sign consent forms describing the fetus' age and the steps to be taken to save its life.

Republicans named the legislation the Pain-Capable Unborn Child Protection Act, citing what they said is evidence that fetuses at 20 weeks can feel pain.

"It's time to open our eyes and allow our consciences to catch up with our technology," said Rep. Trent Franks, R-Ariz., the bill's chief sponsor.

Abortion rights advocates say the measure violates women's privacy and cite doctors' groups, like the American Congress of Obstetricians and Gynecologists, that have gathered evidence that fetal pain is unlikely until several weeks later.

"You want to talk about pain? Let's talk about the agony of a woman who's raped and again violated by unnecessary government intrusion," said Rep. Lois Frankel, D-Fla.

The 1973 Supreme Court Roe v. Wade decision established a constitutional right to abortion but allowed states to bar the procedure after viability — the point where the fetus could survive if born. Disputes over when viability is reached have provoked numerous legislative battles ever since.

Forty-two states bar abortions after certain points in pregnancies, including 10 with bans at 20 weeks, according to the Guttmacher Institute, a research group that supports access to abortion.

Statistics from the federal Centers for Disease Control and Prevention show that of 730,000 abortions in 2011, 1.4 percent — or about 10,000 — were performed after 20 weeks of pregnancy.

As with the original bill, the new measure permits abortions for minors who were victims of incest if the assault is reported to police or government agencies serving targets of child abuse. It allows no exemption for adult victims of incest.

Doctors performing banned abortions would face imprisonment of up to five years plus fines. People could also bring civil actions against doctors who violate the measure's requirements.