WASHINGTON — House Speaker Paul D. Ryan commiserated with President Donald Trump Thursday after the president launched a Twitter assault on the group of rebellious Republicans known as the Freedom Caucus.

"I understand the frustration, I share the frustration," Ryan told reporters Thursday, when asked to respond to Trump's threat to campaign against fellow Republicans.

Freedom Caucus members, who back limited government and have defined themselves in opposition to the Washington establishment, have been a major headache for GOP leaders. Ever since the Republicans took control of the House in 2010, conservative refusal to back key bills to fund government agencies has forced GOP leaders to negotiate with Democrats for the votes they need.

Freedom Caucus members helped lead the charge against former Speaker John A. Boehner, R-Ohio.

The caucus was blamed by many Republicans last week for torpedoing the leadership's plan, backed by Trump, to make significant changes to Obamacare.

Still, Trump's threat to "fight them" in the 2018 elections was an extraordinary step. Trump had previously made electoral threats against wayward members of his party, but Thursday's tweet was especially direct, threatening to treat them the same way as Democrats.

"The Freedom Caucus will hurt the entire Republican agenda if they don't get on the team, & fast," Trump tweeted. "We must fight them, & Dems, in 2018!"

Freedom Caucus members have begun pushing back aggressively. A spokeswoman for the group argued on Twitter that Trump did not have his facts right and that Republican moderates were equally responsible for sinking the health care bill.

Finding Trump supporters to challenge Republicans in a primary would be hard and could further thrust the GOP into civil war.

Trump, despite low poll numbers nationally, remains popular in core Republican districts. Many members of Congress, however, ran ahead of him in their districts in the last election.

The president has also suggested he might be open to cutting deals with Democrats, something the White House has discussed but not followed through on. That would also be difficult, given the rancor on the left.

Ryan said Thursday that the best path is for Republicans to come together on health care and other issues

"About 90 percent of our conference is for this bill to repeal and replace Obamcare, and about 10 percent are not. And that's not enough to pass a bill," he said.

"What I am encouraging our members to do is to keep talking with each other until we can get the consensus to pass this bill. But it's very understandable that the president is frustrated that we haven't gotten to where we need to go, because this is something that we all said we would do."