President Trump on Friday announced that his flailing nominee for director of national intelligence has dropped out of consideration, blaming the media for his exit.

“Our great Republican Congressman John Ratcliffe is being treated very unfairly by the LameStream Media,” the president tweeted. “Rather than going through months of slander and libel, I explained to John how miserable it would be for him and his family to deal with these people John has therefore decided to stay in Congress where he has done such an outstanding job representing the people of Texas, and our Country. I will be announcing my nomination for DNI shortly.”

“While I am and will remain very grateful to the President for his intention to nominate me as Director of National Intelligence, I am withdrawing from consideration,” the congressman tweeted shortly thereafter.

“I was humbled and honored that the President put his trust in me to lead our nation’s intelligence operations and remain convinced that when confirmed, I would have done so with the objectivity, fairness and integrity that our intelligence agencies need and deserve,” Ratcliffe continued. “However, I do not wish for a national security and intelligence debate surrounding my confirmation, however untrue, to become a purely political and partisan issue. The country we all love deserves that it be treated as an American issue.”

Ratcliffe’s exit comes after the White House struggled to guarantee enough Republican votes for his nomination. It’s the latest moment of turmoil for the Office of the Director of National Intelligence (ODNI), the department that serves as a hub for the nation’s 17 intelligence agencies.

As a Texas Republican who serves on the House intelligence committee, Ratcliffe’s nomination drew sharp scrutiny in recent weeks.

First, within 24 hours of Trump’s announcement of the nomination, reports emerged that he had inflated his national security credentials by falsely claiming to have prosecuted terrorists. Then, news broke that one of his campaign claims—that he arrested 300 undocumented immigrants in one day—was patently false. And last, a series of reports highlighted his apparent lack of engagement on the House intelligence committee.

The congressman’s reputation as a close political ally of the president’s had already generated significant concerns among national security and intelligence officials about his fitness for the post.

Intelligence officials pride themselves on sharing information with policymakers that isn’t colored by political bias, and some feared Ratcliffe would break from that practice. As The Daily Beast reported, the congressman was responsible for popularizing a conspiracy theory about the existence of an anti-Trump “secret society” within the FBI.

Even before his withdrawal, ODNI had been grappling with an unpredictable administration. The White House recently asked for a list of its top officials in an apparent effort to find people who would be eligible to serve as acting DNI in the interregnum between current Director Dan Coats—who is set to leave on August 15—and Ratcliffe.

Coats’ current second-in-command, Sue Gordon, would automatically become the acting director upon his absence. But the Trump administration has been looking for ways to hopscotch her and put someone perceived as politically loyal in that role, according to The New York Times. That’s likely the reason they asked for a list of possible alternatives.

Trump’s fraught relationship with his spy agencies goes back to the earliest days of his presidency, which began under the shadow of an FBI counterintelligence investigation into his campaigns contacts with Russians. When Special Counsel Robert Mueller took over that investigation, the president grew incensed.

Along with allies on Capitol Hill and at Fox News, he dedicated considerable time and energy to lambasting Mueller and other senior officials in intelligence and law enforcement. He decried the “Deep State,” blaming bureaucrats and Obama holdovers for his legal woes.

But even after Trump installed his own nominees throughout the nation’s national security agencies, those problems persisted. His top two people at the Justice Department, Attorney General Jeff Sessions and Deputy Attorney General Rod Rosenstein, both drew his ire; Sessions for recusing himself from the Russia probe, and Rosenstein for handing it over to Mueller.

Meanwhile, other political appointees disappointed him as well. When Coats and CIA Director Gina Haspel told Congress in an open hearing earlier this year that the Iranian government was complying with the nuclear deal and that the North Koreans were continuing their belligerent behavior, Trump tweeted that they needed to go “back to school.”

The next morning, the White House abruptly canceled the pair’s daily briefing of the president.