After weeks of negotiations, the Republican healthcare bill passed the House of Representatives 217 to 213.
It was just enough support to push the legislation through, sending it to the Senate for consideration.
No Democrats voted in favour.
The vote to dismantle former President Barack Obama’s signature healthcare law is Donald Trump’s first major political win.
The bill was previously abandoned when Republicans were unable to agree on its provisions.
Mr Trump says Obamacare is now “dead”.
“This is a great plan. I actually think it will get even better. And this is make no mistake, this is a repeal and replace of Obamacare, make no mistake about it. Make no mistake.”
It is also a political victory for House Speaker Paul Ryan, demonstrating his ability to pull together a fractured Republican caucus.
“The truth is, this law has failed and it is collapsing. Premiums are skyrocketing and choices are disappearing and it is only getting worse, spiraling out of control. And that is why we have to repeal this law and put in place a real, vibrant market place, with competition and lower premiums for families.”
Around 20 million Americans gained healthcare coverage under Obama’s 2010 Affordable Care Act.
But Republicans have long attacked it, seeing the program as government overreach and complaining that it drives up healthcare costs.
The Republican bill aims to repeal most Obamacare taxes, including a penalty for not buying health insurance.
It would slash funding for Medicaid, the program that provides insurance for the poor, and roll back much of Medicaid’s expansion.
Soon after the vote, Republicans went to the White House Rose Garden to celebrate their victory.
Mr Trump says he’s confident of the future of the bill.
“I went through two years of campaigning and I’m telling you no matter where I went, people are suffering so badly with the ravages of Obamacare. And I will say this that, as far as I’m concerned your premiums, they’re going to start to come down. We’re going to get this passed through the Senate. I feel so confident.”
But Democrats have slammed the bill.
Protesters rallied in Washington DC, shouting at congress members as they left Capitol Hill.
Democrats are hoping that the vote will spark a voter backlash in next year’s mid-term congressional elections.
Democratic Minority Leader Nancy Pelosi questioned the timing of the bill.
“This is not a health bill. This is a tax bill disguised as a health bill to have one of the biggest transfers of wealth from working families to the richest people and corporations in our country. That’s why they have to do it now so they can do their tax bill.”
Independent Senator Bernie Sanders is accusing Mr Trump of being out of touch with working-class Americans.
“When you throw 24 million people off of health insurance, when you raise premiums for older workers, When you defund Planned Parenthood and when you cut Medicaid by $800 billion, and then on top of all of that, you give 300 billion in tax breaks to the top two per cent. That is not standing with the working class of this country, that is going to war against the working class of this country.”
The legislation now faces new hurdles in the Senate, where the Republicans have only a 52-seat majority in the 100-seat chamber and where just a few Republican defections could sink the bill.