The US House of Representatives passed a bill on Tuesday night that would jail doctors for up to five years if they performed an abortion on a woman after 20 weeks of pregnancy.

Although the White House has promised to veto the legislation in the unlikely event it passes the Senate and campaigners argue it would be unconstitutional anyway, the symbolic vote served as a reminder of the strength of anti-abortion sentiment among Republicans.

Many political strategists had thought the party would focus less on abortion in future after performing badly among women voters in the 2012 presidential election, but the House Republican leadership backed the bill, which sought to capitalise on national outrage at the recent conviction of a Pennsylvania doctor for murdering live-born babies.

In a vote largely along party lines, 228 voted for the so-called Pain-Capable Unborn Child Protection Act and 196 voted against. Six Democrats and six Republicans voted across party lines. The bill's title reflects disputed medical claims that a foetus in the second trimester of pregnancy is capable of feeling pain.

"After 20 weeks the unborn child reacts to stimuli that would be recognised as painful if applied to an adult human, for example, by recoiling," said the text of the bill [PDF].

Pro-choice campaigners argue that not only is this claim misleading but that such legislation would violate supreme court rulings that abortion rights are protected under the US constitution.

In comments that attracted ridicule on Monday, the Texan Republican Michael Burgess defended the bill by appearing to suggest that foetuses masturbate. "Watch a sonogram of a 15-week baby and they have movements that are purposeful," he said. "They stroke their face. If they're a male baby they may have their hand between their legs. If they feel pleasure why is it so hard to think that they could feel pain?"

The House Speaker, John Boehner, rejected suggestions the symbolic bill would damage Republican attempts to broaden their reach among women. "Listen, after this Kermit Gosnell trial [in Pennsylvania] and some of the horrific acts that were going on, the vast majority of the American people believe in the substance of this bill and so do I," he said.

The bill would ban abortion from being performed "if the probable post-fertilisation age of the unborn child is 20 weeks or greater, except where necessary to save the life of a pregnant woman whose life is endangered by a physical disorder, illness, or injury".

Anyone violating the act would be subject to a fine or imprisonment for up to five years.

Republicans added a late amendment that would also exempt women who had been raped despite claiming such cases were rare.

On Monday the White House said it would oppose the legislation first proposed by the Arizona Republican Trent Franks which it said would "unacceptably restrict women's health and reproductive rights and is an assault on a woman's right to choose [PDF]".

"This bill is a direct challenge to Roe vs Wade and shows contempt for women's health and rights, the role doctors play in their patients' health care decisions and the constitution," added the administration. "If the president were presented with this legislation his senior advisors would recommend that he veto this bill."

Nonetheless abortion rights are under growing attack among state legislatures across the US and the passage of the bill is likely to embolden anti-abortion campaigners and reignite one of the most controversial flashpoints in US politics.