The US House of Representatives has passed a legislation that would criminalise abortions after 20 weeks of pregnancy with exceptions for instances where the life of the mother is at risk and in cases involving rape or incest.

The bill, sponsored by Representative Trent Franks was passed by the House on Tuesday by a vote of 237 for and 189 against, largely on party lines. The legislation would make it a crime to perform or attempt an abortion after 20 weeks of pregnancy, with the possibility of a fine, up to five years in prison or both, the Hill magazine reported.

It is likely to face a tough sell in the Senate. A similar bill passed the House in 2015 but was blocked by Senate Democrats.

With only a 52-seat majority it would be unlikely Senate Republicans could gather the 60 votes needed to move the legislation to President Donald Trump’s desk.

Senator Lindsey Graham said he would reintroduce a companion bill in the Senate soon.

The White House said on Monday that it “strongly supports” the bill and “applauds the House of Representatives for continuing its efforts to secure critical pro-life protections”.

The bill is a top priority of anti-abortion groups, which argue a foetus can feel pain at 20 weeks gestation and later.

“It’s past time for Congress to pass a nationwide law protecting unborn children from the unspeakable cruelty of late-term abortion,” said Marjorie Dannenfelser, president of the Susan B. Anthony List, an anti-abortion group in D.C.

Abortion rights groups, however, condemned the bill. “The agenda behind this bill is clear: To shame women and to ban safe, legal abortion,” said Dana Singiser, vice-president for Government Relations and Public Policy for Planned Parenthood.