The US House of Representatives has passed a revised healthcare bill that Republicans hope will replace Obamacare.
By a vote of 217-213, Republicans obtained just enough votes to push the legislation through the House, sending it to the Senate for consideration where it could run into difficulties.
No Democrats voted for the House bill.
It is President Donald Trump's his biggest legislative victory, but it is also a win for House Speaker Paul Ryan. It demonstrates his ability to pull together a fractured Republican caucus after two failed attempts this year to win consensus on the healthcare legislation.
Democrats are hoping that the Republicans' vote to repeal Obamacare will spark a voter backlash in next year's midterm congressional elections.
Some 20 million Americans gained healthcare coverage under Obama's 2010 Affordable Care Act, which has recently gathered support in public opinion polls. But Republicans have long attacked it, seeing the program as government overreach and complaining that it drives up healthcare costs.
Earlier, House Majority Leader Kevin McCarthy said the party's leadership believed it had enough votes for the bill to pass, despite opposition from Democrats.
President Trump made the repeal of his predecessor's signature law a central campaign promise.
He has played a personal role this week in persuading wavering Republicans to support the legislation, known as the American Health Care Act (AHCA).
The first attempt at replacing Obamacare collapsed in March, with opposition from both moderates and conservatives inside the Republican party.
What is in the revised bill?
In an effort to win votes of Republicans who were against the initial healthcare bill, Republicans amended it several times, trying to balance different demands.
Several key Republicans then reversed course, partly due to an amendment by Congressman Fred Upton.
It provides $US8 billion over five years towards coverage for sick people, including those with cancer, who could otherwise face higher costs under the new system.
But health policy experts say the amount is not enough to cover the cost of coverage for the sickest patients.
The American Medical Association said millions of people would lose their coverage as a result of the proposal.
"None of the legislative tweaks under consideration changes the serious harm to patients and the health care delivery system" that the bill could cause, the association's president said.
The bill has yet to be assessed by the Congressional Budget Office (CBO), a nonpartisan group of budget analysts and economists, which typically provides an estimate on how much the bill would cost and how many people would be left uninsured.
The CBO projected in late March that the previous version of the Republican healthcare bill would cut the federal deficits by $337bn over a 10-year period.
However, it said 24 million people would lose health insurance.
Where do Democrats stand?
No Democrats support the revision, and say the amount provided by the Upton amendment was inadequate.
Senate minority leader Chuck Schumer said: "The Upton amendment is like administering cough medicine to someone with stage four cancer."
That meant the 216 votes necessary to pass the legislation would have to come from Republicans, who control both legislative chambers in Congress.
What has changed from Obamacare?
Why did the first bill fail?
The first attempt collapsed in disarray in March, with opposition from both moderates and conservatives inside the Republican party.
They feared too many people with pre-existing medical conditions would be left unable to afford health coverage.
President Barack Obama's overhaul of healthcare extended insurance coverage to millions of Americans, but some have experienced rising premiums in recent years.
One of its popular elements is that it bans insurers from denying coverage to patients who are ill with "pre-existing conditions".
President Trump has insisted the revised bill would keep that, although it was thought that states would be able to opt out of making that an absolute provision.
Conservatives want to see a complete rollback of Obamacare, while moderates are concerned about losing voters who like the existing law.