President Donald Trump has declared Obamacare “dead” after the Republican healthcare bill was narrowly passed by the lower chamber of Congress.

The 217-213 vote marked his first legislative victory and goes some way to keeping a key campaign promise to roll back his predecessor’s law.

Democrats say the American Health Care Act will leave millions uninsured.

The bill now heads to the Senate, where Republicans have indicated they will cast it aside and write a new law.

Protesters shouted “Shame on you!” as lawmakers left Capitol Hill after the knife-edge vote.

But there were celebrations moments later on the White House lawn, where the president laid on a reception for Republicans in the House of Representatives.

Six weeks ago, their healthcare attempts appeared doomed when they did not have enough support to have a vote.

But that bill has undergone several revisions to satisfy both the conservative and moderate wings of the Republican party.

“Make no mistake, this is a repeal,” said a triumphant Trump in the Rose Garden. Obamacare, he added, was “essentially dead”.

“Premiums will be coming down, deductibles will be coming down, but very importantly it’s a great plan.”

The Democrats think the effect of this bill would be the opposite, stripping insurance from the poor, giving tax breaks to the wealthy and casting doubt on health provisions for the chronically sick.

“Thousands of Americans would die because they would no longer have access to care,” said Senator Bernie Sanders.

Groups representing hospitals and doctors have also expressed concerns about the Republican plan, which they say has yet to be properly assessed.

The ill-fated Republican bill in March would result in 24 million more Americans losing insurance within a decade, the nonpartisan Congressional Budget Office said at the time.

One amendment added since then to placate conservatives means states can opt out of providing essential benefits such as cancer treatment and emergency room visits.

And when $8bn (£6.2bn) over five years was thrown in towards coverage for sick people who otherwise might face higher costs, several moderate Republicans changed course and backed it.

About 20 million Americans gained healthcare coverage under President Barack Obama’s 2010 Affordable Care Act, but Republicans viewed it as an overreach of the federal government and said patients had less choice and higher premiums.

The New York attorney general said on Thursday evening that he would challenge the bill in court if it became law, on the basis that it would deny people access to care.

The bill, if it becomes law, would mark a major overhaul in the US health system.

But key elements could be ditched by Republican senators, who have said they will start fresh.

Republican Senator Lisa Murkowski said she would like “a clean slate”, while Senator Bob Corker said the current bill has “zero” chance in the Senate.

The party controls the chamber 52-48, meaning it can lose no more than two Republicans in order for it to pass.

If the Senate passes its own bill, the plan then goes back to the House for approval or more negotiations and amendments.

What’s changed from Obamacare?

*New bill repeals the individual mandate requiring those who can afford it to have health insurance

*Ditches Obamacare requirement for companies with 50 or more staff to provide insurance coverage for employees.

*Keeps element allowing under-26s to stay covered on parents’ policies

*Enables insurers to charge at least five times as much to older customers.

*States can opt out of essential benefits like emergency care and cancer treatment

*And they can waive the guarantee to provide healthcare to people with pre-existing conditions.