WASHINGTON — Republican leaders drove their long-promised legislation to dismantle Barack Obama’s health care law over its first big hurdles in the House on Thursday, claiming fresh momentum despite cries of protest from right, left and center.

After grueling all-night sessions, the Energy and Commerce and Ways and Means committees both approved their portions of the bill along party-line votes.

The legislation, strongly supported by President Donald Trump, would eliminate the unpopular tax penalties for the uninsured under the Affordable Care Act, replacing Obama’s law with a conservative blueprint likely to cover far fewer people but — Republicans hope — increase choice.

The vote in Ways and Means came before dawn, while the Energy and Commerce meeting lasted past 27 hours as exhausted lawmakers groped for coffee refills, clean shirts and showers.

RELATED: GOP overhaul of Affordable Care Act could hurt Illinois worse than most

Angry Democrats protested that Republicans were acting in the dead of night to rip insurance coverage from poor Americans. But Republican leaders sounded increasingly confident that, after seven years of empty promises about undoing Obama’s law, they might finally be able to overcome their own deep divisions and deliver a bill to Trump to sign.

“This is the closest we will ever get to repealing and replacing Obamacare,” Speaker Paul Ryan of Wisconsin said at a press briefing where he arrived in shirt-sleeves to deliver a wonky power-point presentation on the GOP bill, part TED Talk and part “Schoolhouse Rock.”

“The time is here. The time is now. This is the moment. And this is the closest this will ever happen,” Ryan said.

Leaders are aiming for passage by the full House in the next couple of weeks, and from there the legislation would go to the Senate and, they hope, on to Trump’s desk. The president has promised to sign it, declaring over Twitter on Thursday, “We are talking to many groups and it will end in a beautiful picture!”

Yet at the same time the president is leaving himself a political out, privately telling conservative leaders that if the whole effort fails, Democrats will ultimately shoulder the blame for the problems that remain. That’s according to a participant in the meeting Wednesday who spoke only on condition of anonymity to relay the private discussion.

Democrats reject that notion, and the entire GOP effort.

“What we have seen is the Republicans’ long-feared and job-killing health bill that means less coverage and more cost to American people,” said House Minority Leader Nancy Pelosi of California. “I don’t think the president really knows what he’s talking about.”

The GOP legislation would kill Obama’s requirement that everyone buy insurance by repealing the tax fines imposed on those who don’t. The bill would replace income-based subsidies Obama provided with tax credits based more on age, and insurers would charge higher premiums for customers who drop coverage for over two months.

The extra billions Washington has sent states to expand the federal-state Medicaid program would phase out, and spending on the entire program would be capped at per-patient limits. Around $600 billion in tax boosts that Obama’s statute imposed on wealthy Americans and others to finance his overhaul would be repealed.

Insurers could charge older customers five times more than younger ones instead of the current 3-1 limit but would still be required to include children up to age 26 in family policies, and they would be barred from imposing annual or lifetime benefit caps.

Democrats said the Republicans would yank health coverage from many of the 20 million people who gained it under Obama’s statute, and drive up costs for others. And they accused Republicans of hiding bad news by moving ahead without official estimates from the nonpartisan Congressional Budget Office on the bill’s cost to taxpayers and its anticipated coverage.

And even as Republican leaders expressed confidence, enormous obstacles remained. A growing coalition of interest groups has lined up in opposition, including AARP and numerous medical professionals, from mental health providers to doctors, nurses, hospitals and more. Republican senators from politically divided states have voiced qualms about the changes to Medicaid, and opposition remains from conservative lawmakers and groups.

There were signs, though, that some of that conservative opposition could be softening amid concerted lobbying from Trump, Vice President Mike Pence and other administration officials. Trump dined Wednesday night with Sen. Ted Cruz of Texas, a skeptic of the bill, and kept up his wooing efforts Thursday, inviting a group of lawmakers including two influential House conservatives to lunch at the White House.

One of them, Rep. Mark Meadows of North Carolina, who chairs the House Freedom Caucus, said afterward that there are still “major concerns that need to be addressed, but I really appreciate the president’s willingness to consider issues that are important to all Americans.”

Meadows and other conservatives were pushing the administration to change a provision in the House bill that phases out extra Medicaid dollars for states beginning in 2020; they hoped to move the date up to 2018. But that would make the bill more difficult to swallow for a pivotal group of Republican senators whose states expanded Medicaid under the Obama law.

House Majority Leader Kevin McCarthy rejected any need for change. “It’s a good bill,” he said. As for how to attract conservative lawmakers, he asked rhetorically, “They’re going to support Obamacare?”

The Senate loomed as perhaps the tougher challenge, as GOP Sen. Tom Cotton of Arkansas voiced new objections over Twitter. “House health care bill can’t pass Senate w/o major changes. To my friends in House: pause, start over. Get it right, don’t get it fast,” Cotton wrote.

And in another measure of concern, the chief medical officer at Medicaid, Dr. Andrey Ostrovsky, registered his opposition over Twitter, saying he was aligning himself with medical professionals opposed to the bill “despite political messaging from others at HHS,” the Health and Human Services Department.

Associated Press reporters Ricardo Alonso-Zaldivar, Julie Bykowicz, Andrew Taylor, Kevin Freking, Mary Clare Jalonick, Stephen Ohlemacher and Ken Thomas contributed to this report.