The US House of Representatives has narrowly approved legislation to repeal major portions of the Affordable Care Act, or Obamacare, and replace it with a Republican healthcare plan.

The vote to repeal former president Barack Obama's signature domestic achievement, which enabled 20 million more Americans to get health insurance, was Mr Trump's biggest legislative win since he took office in January.

With the 217-213 vote, Republicans obtained just enough support to push the legislation through the House, sending it to the Senate for consideration. No Democrats voted for the bill.

The legislation is by no means a sure thing in the Senate, where the Republicans hold a slender 52-seat majority in the 100-seat chamber and where only a few Republican defections could sink it.

Despite holding the White House and controlling both houses of Congress, Republicans have found that overturning Obamacare is politically fraught, in part because of voter fears that many people will lose their health insurance as a result.

Republicans have long criticised Obamacare as government overreach.

Within an hour of the vote, Mr Trump celebrated in the White House Rose Garden.

"I went through two years of campaigning and I'm telling you, no matter where I went, people were suffering so badly with the ravages of Obamacare," Mr Trump said.

"We are going to get this passed through the Senate. I am so confident."

While the bill's fate in the Senate is uncertain, its House passage could boost Mr Trump's hopes of pushing through other big ticket items on his agenda, such as tax reform.

The failure of two previous efforts on the healthcare legislation had raised questions about how much Republicans could work together to help Mr Trump fulfill his campaign pledges.

Mr Obama's 2010 Affordable Care Act expanded Medicaid, the government insurance programme for the poor; provided income-based tax credits to help the poor buy insurance on individual insurance markets set up by the law, and required everyone to buy insurance or pay a penalty.

Republicans have blamed it for driving up healthcare costs and have argued that it has since failed.

The Republican bill, called the American Health Care Act, would repeal most Obamacare taxes, which paid for the law, rollback the Medicaid expansion and slash the programme's funding, repeal the penalty for not purchasing insurance and replace the laws tax credits with flat age-based credits.

In a sign of the challenges ahead for the legislation, nearly every major medical group, including the American Medical Association, American Hospital Association and the AARP, strongly opposed the Republican bill.

Many said last-minute amendments further eroded protection for the most vulnerable groups, including the sick and elderly.