President Trump announced Friday that Rep. John Ratcliffe, his embattled pick to lead the nation’s intelligence community, was withdrawing from consideration and will remain in Congress after lawmakers raised questions about his qualifications and whether he had padded his résumé.

Trump said he will announce a new pick for director of national intelligence shortly.

In tweets, Trump said that Ratcliffe (R-Tex.) was being treated “very unfairly” by the media.

“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,” Trump wrote. “John has therefore decided to stay in Congress where he has done such an outstanding job representing the people of Texas, and our Country.”

Even by the tumultuous standards of the Trump administration, Ratcliffe’s nomination, which fell apart in less than a week, was a spectacular flameout.

The president announced via tweet Sunday that he intended to nominate Ratcliffe as director of national intelligence to replace Daniel Coats. That came as a surprise to White House aides, who had not vetted the three-term congressman and believed that he was in the running for a different position, possibly secretary of homeland security, according to officials familiar with the matter, who like others spoke on the condition of anonymity to discuss internal deliberations.

Eager to show that he had a ready replacement, Trump sent the tweet after seeing news reports that Coats was resigning and Ratcliffe was a possible nominee, the officials said.

Trump and Coats, a former senator and ambassador to Germany, had a rocky relationship. But Trump liked Ratcliffe because he was a strident critic of special counsel Robert S. Mueller III’s investigation, and the two had spent time together at the White House in recent weeks, officials said.

Trump seemed to think that the announcement would be well received, according to the officials. But key Republicans in Congress quickly signaled that Ratcliffe lacked the national security expertise that the job requires by law. Ratcliffe’s colleagues also described him as one of the least involved members of the House Intelligence Committee, who hasn’t traveled abroad to get a front-line view of intelligence operations since he joined the committee seven months ago. That raised doubts about whether he was prepared to oversee a sprawling intelligence bureaucracy of 17 agencies with a budget of about $60 billion.

Records and interviews with former colleagues also showed that Ratcliffe had exaggerated his role in terrorism and immigration enforcement cases when he served as a federal prosecutor in Texas. During his campaign and on his congressional website, Ratcliffe had boasted that he “arrested 300 illegal immigrants on a single day.” That turned out not to be true. Former colleagues also said he didn’t play a significant role in a major terrorism case as he has claimed.

In a statement issued shortly after Trump’s tweets Friday, Ratcliffe said that he remained convinced that if confirmed by the Senate he would have served “with the objectivity, fairness and integrity that our intelligence agencies need and deserve.”

“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,” he said. “The country we all love deserves that it be treated as an American issue. Accordingly, I have asked the President to nominate someone other than me for this position.”

Trump closely followed the negative coverage of Ratcliffe this week, a senior White House official said.

On Thursday, Trump began polling advisers about whether Ratcliffe could be confirmed and commented to allies during a trip to Ohio that he was getting “crushed” by the media, in the words of one person who spoke to Trump.

Ratcliffe felt like he wasn’t getting the support he needed in the Senate, where Majority Leader Mitch McConnell (R-Ky.) and Intelligence Committee Chairman Richard Burr (R-N.C.) offered only tepid support, and that winning confirmation would be an uphill battle, according to a senior administration official.

Ultimately, Trump decided that he didn’t want to back Rat­cliffe if the congressman was uncertain about his prospects, the senior administration official said.

In an exchange with reporters Friday afternoon, Trump defended the White House’s failure to scrutinize Ratcliffe’s background.

“I give out a name to the press and they vet for me. We save a lot of money that way,” Trump said.

Trump insisted that Ratcliffe would have had support from Republicans and claimed not to know that members of his own party hadn’t embraced the congressman.

But Trump understood that the path forward wouldn’t be easy.

“Do you want to go through this for two or three months or would you want me to, maybe, do something else?” Trump said he asked Ratcliffe. “And he thought about it. I said, ‘It’s going to be rough.’ ”

Trump defended the decision to pull out, saying that the White House was “very early in the process” of the nomination. “We hadn’t even started.”

Responding to criticism that Ratcliffe lacked significant national security expertise, Trump said, “He wasn’t in that world that much. I think he would’ve picked it up very quickly.”

Trump said that he has a list of three potential nominees who are “very well-known people” among intelligence agencies, and that he will consider them over the weekend and possibly make an announcement Monday.

Trump also indicated that the current principal deputy director of national intelligence, Sue Gordon, might serve as the acting director when Coats leaves office Aug. 15. Trump had previously been unclear whether he expected her to fulfill the role. By law, the principal deputy director becomes the acting director when that position is vacant.

“I like Sue Gordon. Sue Gordon is there now, and I like her very much. I’ve always liked her,” Trump said adding, “Certainly she will be considered for the acting.”

But others in the White House have said that Trump does not want Gordon to serve as the acting director. Burr, as well as Democratic lawmakers, have objected to the idea of replacing her with a political loyalist and have insisted that Gordon remain.

One person familiar with White House deliberations said the president has considered asking former Republican congressman Pete Hoekstra, now the ambassador to the Netherlands, to return to the United States and serve as the acting director. To do that, Trump would probably have to fire Gordon, reassign her or accept her resignation.

Trump could also appoint another official who has already been confirmed by the Senate to step into the deputy director role and then serve as acting director.

Gordon is widely admired among Democrats and Republicans in Congress, and Burr offered a quiet endorsement Friday.

“I respect John Ratcliffe’s decision to withdraw his name from consideration . . . and I appreciate him considering serving his nation in a new role,” Burr said. “As the White House determines its next nominee, I’m heartened by the fact that ODNI has an experienced and capable leadership team to help see it through this transition.”

At the Office of the Director of National Intelligence, officials said Gordon would not be distracted by the turmoil.

“We are aware that the president is considering his options,” a spokeswoman for the ODNI said. “Sue has not been contacted by the White House. In the absence of any decision, Sue remains focused on serving the president, the intelligence community and the nation’s interest.”

Gordon was in Utah on Friday, speaking at a security conference hosted by Republican Rep. Chris Stewart. She did not address the controversy over Ratcliffe or her future in the intelligence community. But she did indicate that she had been looking forward to retiring.