In public, President Trump is standing by House Speaker Paul Ryan over the failed Obamacare replacement bill.

“I like Speaker Ryan; he worked very, very hard,” Trump said in the Oval Office after Ryan on Friday pulled the legislation from the House floor for lack of support. Instead, the president pinned the responsibility on Democrats.

Behind the scenes, though, the president’s aides blame Ryan for the bill’s embarrassing defeat, which stymied a Republican goal for more than seven years, a senior administration official said.

Asked whether Trump, Ryan, or the Freedom Caucus chairman, North Carolina Republican Mark Meadows, would be most to blame if the bill fails, the official said Ryan.

Ryan inoculated himself somewhat from bearing sole blame for the bill’s failure; in the middle of the day Friday, he went to the White House to tell Trump personally that there weren’t enough votes. Later, Ryan recommended the bill be pulled from the floor and Trump agreed.

Several House Republicans, including the chairman of the Appropriations Committee, announced in the morning that they would vote against the measure, making its prospects grim.

Trump and his aides were heavily invested in the legislation. On Thursday, Trump’s chief strategist, Stephen Bannon, took the unusual step of traveling to Capitol Hill to deliver an ultimatum: Take a vote Friday, win or lose. Ryan had sought to carefully build a majority for the bill, and it would be highly unusual for him to call the vote without knowing if it would pass.

Ryan had little choice but go along with the gambit. Trump said Friday at the White House, before the legislation was pulled, that Ryan shouldn’t lose his job if the bill went down. He also said “no” when asked if the bill had been rushed or if he regretted pursuing a replacement of the Affordable Care Act ahead of other priorities such as a tax overhaul.

Democrats were to blame for the bill’s failure because they didn’t support the legislation, Trump said afterward. The bill was written and introduced with no Democratic input.

“I think the real losers are Nancy Pelosi and Chuck Schumer,” Trump said, referring to the Democratic leaders of the House and Senate, respectively. “Because now they own it, they 100 percent own it.”

A senior Republican aide said that a Trump tweet on Friday indicated he would blame the Freedom Caucus for the bill’s failure. Ryan has been in close contact throughout the bill’s development and consideration, and both politicians understood that they had much at stake in the legislation, the aide said, calling the bill the most conservative version of an Obamacare repeal that could pass Congress.

“The president gave his all in this effort,” Ryan said at a news conference after pulling the bill. “He did everything he possibly could to help people see the opportunity we had with this bill. He’s really been fantastic.”

Several Trump associates have already laid groundwork to blame the speaker, who butted heads with Trump repeatedly before his election.

“I think Paul Ryan did a major disservice to President Trump, I think the president was extremely courageous in taking on health care and trusted others to come through with a program he could sign off on,” Chris Ruddy, chief executive officer of Newsmax and a longtime friend of Trump’s, said last week. “The president had confidence Paul Ryan would come up with a good plan and to me, it is disappointing.”