Director of National Intelligence Daniel Coats will leave his position next month, President Trump announced Sunday, capping a tumultuous relationship in which the two were often at odds over the wisdom of negotiating with Russia, the status of Iran’s nuclear weapons program and the severity of foreign threats to U.S. elections. 

Trump said in a tweet that he would nominate Rep. John ­Ratcliffe (R-Tex.), a third-term congressman and prominent supporter, to replace Coats.

The announcement comes just days after former special counsel Robert S. Mueller III warned on Capitol Hill that Russia will seek to interfere in U.S. elections in 2020.

Ratcliffe launched a spirited defense of Trump at that hearing on Wednesday, grilling Mueller about why he had provided evidence of Trump’s possible obstruction of justice in his probe if, as Mueller wrote, he never intended to decide whether the president had committed a crime. 

“You wrote 180 pages . . . about decisions that weren’t reached, about potential crimes that weren’t charged or decided,” ­Ratcliffe said, arguing that Mueller had deviated from normal prosecutorial standards and treated Trump unfairly. 

In an appearance Sunday on Fox News, Ratcliffe characterized Mueller’s report as an untrustworthy document written by aides and lawyers for Hillary Clinton. The Justice Department is investigating the origins of the probe, which also examined possible coordination between Russia and the Trump campaign. Mueller’s report “identified numerous links between individuals with ties to the Russian government and individuals associated with the Trump Campaign” but found that “the evidence was not sufficient to support criminal charges.”

Trump called Ratcliffe a “highly respected Congressman” who “will lead and inspire greatness for the Country he loves.” He thanked Coats “for his great service to our Country.” 

For months, Coats had recognized that his relationship with Trump, which was never strong, had frayed beyond repair, according to a former senior intelligence official who spoke on the condition of anonymity to discuss the sensitive issue. Coats had felt isolated and excluded from important national security decision-making, the former official said.

In his resignation letter to Trump dated Sunday, Coats said: “The Intelligence Community is stronger than ever, and increasingly well prepared to meet new challenges and opportunities. As we have previously discussed, I believe it is time for me to move onto the next chapter of my life.”

As of late last week, Coats and the White House had agreed that he would step down, according to officials familiar with the matter. Coats was not taken by surprise, and on Sunday, as Trump made the resignation official via tweet, the intelligence director was playing golf in the Washington area, one U.S. official said.

Coats and Trump had been at odds publicly for more than a year. In July 2018, while speaking at a national security conference in Aspen, Colo., Coats infuriated White House officials when he said that if Trump had asked his advice, he would have told him not to meet privately with Russian President Vladi­mir Putin at their summit in Helsinki. The two leaders met without American officials or Trump aides present. 

Coats also did not hide his dismay when he learned, in the middle of an interview at the conference, that the White House had extended an invitation for Putin to visit Washington. 

“That’s going to be special,” Coats said to the audience of a few hundred people, who laughed.

While in Helsinki, Trump sided with Putin against U.S. intelligence agencies, which unanimously concluded that Russian intelligence operatives and their proxies interfered in the 2016 presidential campaign with the goal of helping Trump. 

From the moment Trump nominated Coats in January 2017, he struck many current and former officials as more of a caretaker in the position, a former senator from Indiana and ambassador to Germany who had been coaxed out of anticipated retirement to take on one of the more challenging jobs in U.S. national security. 

As director, Coats regularly attended the president’s daily intelligence briefing session, along with CIA Director Gina Haspel and a senior U.S. intelligence official. But many aspects of the day-to-day running of the intelligence community have fallen to Coats’s deputy, Sue Gordon, a career intelligence officer who has bipartisan support on Capitol Hill. While Ratcliffe awaits confirmation, Gordon probably would assume the duties of intelligence director on an acting basis. 

Trump tweeted, “The Acting Director will be named shortly,” but he didn’t provide a name.

In a statement Sunday, Senate Majority Leader Mitch McConnell (R-Ky.) said that he was “very sorry” to hear about Coats’s departure, adding that he has “devoted decades of his life in service to our country. I was reassured knowing that a man who took such a deliberate, thoughtful, and unbiased approach was at the helm of our intelligence community.”

House Speaker Nancy Pelosi (D-Calif.) said in a statement: “The departure of DNI Coats is bad news for the security of America. As a Republican Senator from Indiana, a George W. Bush-appointed Ambassador to Germany and Director of National Intelligence, he was respected by those on both sides of the aisle as an American patriot.

“DNI Coats’ successor must put patriotism before politics, and remember that his oath is to protect the Constitution and the American people, not the President. ”

There was concern on Capitol Hill that Trump could choose an acting director based more on loyalty than qualifications. 

“If the president names anyone other than Gordon as the acting director, the Hill will raise holy hell,” a congressional official said, speaking on the condition of anonymity to discuss the sensitive decision.  

It is unclear whether Ratcliffe would be confirmed by the Senate. He has no background in intelligence, though he did serve as a terrorism prosecutor and the U.S. attorney in the Eastern District of Texas in the George W. Bush administration. He also served as the mayor of Heath, Tex., a town of about 9,000 outside Dallas.

Intelligence directors have not always been career intelligence officers. But they have also not been such vocal political supporters of a president. Trump has repeatedly blasted the intelligence agencies as having tried to undermine his campaign and has, without evidence, accused former senior intelligence officials from the Obama administration of illegally spying on him. 

Ratcliffe echoed those allegations on Fox News.

“What I do know as a former federal prosecutor is that it does appear that there were crimes committed during the Obama administration,” he said, declining to identify anyone by name. 

Elaborating on his concerns, Ratcliffe said he wanted to know more about the interactions between a Justice Department official, Bruce Ohr, and Fusion GPS, the private investigation company that hired former British intelligence official Christopher Steele to conduct research into Trump and his possible connections to Russia.

Steele’s work has been a focal point of Republican critics of the Russia probe, including Ratcliffe, who say that the FBI improperly used it as a legal justification for beginning surveillance of a former Trump campaign aide.

Ratcliffe also queried Mueller about Steele’s research, but the former special counsel declined to comment because it is the subject of a Justice Department investigation.

“I want to find out if Russia interfered with our election by providing false information through sources to Christopher Steele about a Trump conspiracy that you determined didn’t exist,” Ratcliffe told Mueller.

Trump has given Attorney General William P. Barr unusual authority to investigate the intelligence agencies’ role in the probe of Russian election interference. Under an executive order, Barr is allowed to declassify intelligence about the probe and its origins. Some current and former intelligence officials have said they fear that could expose sensitive sources and methods or be used to distort the facts about how the probe began. 

The Justice Department’s inspector general is also examining aspects of the Russia probe.

Ratcliffe told Fox News that he expected the investigations to determine whether anyone acted improperly or illegally. 

In his confirmation process, senators probably will ask Rat­cliffe about his views on Iran, North Korea, Russia and other hotspots. As a member of the House Intelligence Committee, he has access to classified intelligence reports and assessments that are often contrary to what the president says publicly. Members will grill him on whose analysis he believes is true: Trump’s or the intelligence community’s, the congressional official said. 

In a statement, Senate Minority Leader Charles E. Schumer (D-N.Y.) echoed these points. “It’s clear that Rep. Ratcliffe was selected because he exhibited blind loyalty to President Trump with his demagogic questioning of former Special Counsel Robert Mueller,” he said. “If Senate Republicans elevate such a partisan player to a position that requires intelligence expertise and non-partisanship, it would be a big mistake.”

Coats frequently stated views that contradicted Trump’s claims, which inflamed his relationship with a president who has long ridiculed intelligence agencies as inept and naive. 

From the beginning of Coats’s tenure, he struck some observers as a risky choice. Coats was a well-known Russia hawk, which placed him on the same page as many in the intelligence community but put him at odds with a president who ran on a promise to bring the United States closer to Russia and who consistently rejected the notion that the Kremlin had sought to help him get elected. 

In the Senate, Coats had called on the Obama administration to penalize Russia after it invaded Ukraine, and he co-sponsored a Senate resolution condemning Russia’s use of force to annex Crimea from Ukraine in 2014. Russian officials responded by placing Coats on a shortlist of Americans whose travel to Russia would be restricted. 

“While I’m disappointed that I won’t be able to go on vacation with my family to Siberia this summer, I am honored to be on this list,” Coats tweeted in response. 

In January, Coats further emphasized the distance between him and Trump on a range of key national security issues when he testified to Congress that North Korea was “unlikely to completely give up its nuclear weapons and production capabilities,” which the country’s leaders consider “critical to the regime’s survival.”

That assessment, which Coats said all intelligence agencies shared, undercut the president’s optimistic statements that a deal with North Korea was within reach, in large part thanks to the warm relationship Trump said he was forging with the country’s leader, Kim Jong Un. 

Coats also shared the intelligence agencies’ view that Iran was still in compliance with an international agreement not to produce nuclear weapons, a deal the president pulled out of last fall. 

And Coats warned that Russia probably would interfere in the 2020 presidential election, reprising its efforts to sow discord and distrust among American voters. 

“We continue to see a pervasive messaging campaign by Russia to try to weaken and divide the United States,” Coats said at a White House briefing with reporters last August. “The president has specifically directed us to make the matter of election meddling and securing our election process a top priority.”

U.S. departments and agencies are working to secure the next election and counter Russian efforts. But their work is at odds with statements from Trump, who has sought to play down the threat and recently appeared to make light of Russia’s interference during a meeting with Putin last month at the Group of 20 summit in Japan. 

Earlier this month, Coats created a new position in his office to oversee the intelligence community’s election security efforts. 

Current and former intelligence officials said Coats will be remembered for accurately describing the intelligence agencies’ positions and speaking candidly about threats to the United States, even when it infuriated the president. But some criticized him for not standing up to Trump’s attacks on the intelligence agencies’ integrity, particularly when he accused officials of political bias and crimes

“I think Coats was an honorable man unprepared to succeed in an unusual time,” said John Sipher, a former CIA officer who ran the agency’s operations in Russia. “I personally believe he failed to publicly defend the institutions under his care when it was clear that the commander in chief was off-base. He may well have spoke truth to power in private, but failing to publicly defend his workforce was a mistake.”

David Nakamura contributed to this report.