Dan Coats, one of the most senior national security officials willing to contradict Donald Trump, will leave the post of US director of national intelligence next month, the president has said.

Trump said Coats would go on 15 August and that he will nominate John Ratcliffe, a Texas representative and staunch loyalist, to the post.

The relationship between Coats and Trump was marked by turbulence. Coats’ public, and sometimes personal, disagreements with Trump over policy and intelligence included Russian interference in the US election and North Korean nuclear capabilities.

Trump had long been skeptical of the nation’s intelligence agencies, which provoked his ire by concluding that Russia interfered in the 2016 presidential election with the goal of getting him elected.

In a letter of resignation released on Sunday night, Coats said serving as the nation’s top intelligence official has been a “distinct privilege” but that it was time for him to move on to the next chapter of his life.

Coats had been among the last of the seasoned foreign policy hands brought to surround the president after his 2016 victory, of whom the president steadily grew tired as he gained more personal confidence in the Oval Office, officials said. That roster included the defense secretary Jim Mattis and the secretary of state Rex Tillerson, and later national security adviser HR McMaster.

Coats developed a reputation inside the administration for sober presentations to the president of intelligence conclusions that occasionally contradicted Trump’s policy aims.

His departure had been rumoured for months, and intelligence officials had been expecting him to leave before the 2020 presidential campaign season reached its peak.

Trump’s announcement that Coats would be leaving came days after former special counsel Robert Mueller’s public testimony on his two-year investigation into Russian election interference and potential obstruction of justice by Trump, which officials said both emboldened and infuriated the president.

Coats had been among the least visible of the president’s senior administration officials but, in his limited public appearances, repeatedly seemed at odds with the administration, including about Russia.

For instance, he revealed to Mueller’s investigators how Trump, angry over investigations into links between his campaign and Russia, tried unsuccessfully in March 2017 to get him to make a public statement refuting any connection.

“Coats responded that the Office of the Director of National Intelligence (ODNI) has nothing to do with investigations and it was not his role to make a public statement on the Russia investigation,” Mueller’s report said.

Trump later called Coats to complain about the investigation and how it was affecting the government’s foreign policy. Coats told prosecutors he responded that the best thing to do was to let the investigation take its course.

In February, he publicly cast doubt on the prospects of persuading North Korea to end its nuclear weapons program despite the diplomatic efforts of the administration, which has touted its outreach to the isolated country as one of its most important foreign policy achievements.

Trump publicly bristled at the testimony of Coats, the head of the CIA and other officials who contradicted his own positions on Iran, Afghanistan and the Islamic State group as well as North Korea. The intelligence officials were “passive and naive,” he said in a tweet.

Last July, Coats and the president appeared at odds following Trump’s widely panned news conference in Helsinki alongside the Russian president, Vladimir Putin. Trump said he saw no reason to believe Russia had interfered in the 2016 election, drawing bipartisan criticism and a rebuttal from his intelligence chief.

“We have been clear in our assessments of Russian meddling in the 2016 election and their ongoing, pervasive efforts to undermine our democracy, and we will continue to provide unvarnished and objective intelligence in support of our national security,” Coats said.

Ratcliffe, in his third term, is a relatively newer member of Congress and perhaps not as widely known as Coats was when he took the job. Confirmation takes a simple 51-vote majority, under new Senate rules, but that leaves little room for error with Republicans holding a 53-seat majority.

Ratcliffe appeared Sunday on Fox News Channel’s Sunday Morning Futures and made a number of points that were in sync with Trump’s rhetoric. He said it was time to move on from talk of impeachment, questioned the legitimacy of the Mueller report into Russian election interference and urged investigation into potential wrongdoing during the Obama administration.

His remarks echoed his questioning of Mueller last week, in which the Texas Republican challenged the legal basis for the report’s conclusions.

The Senate Democratic leader, Chuck Schumer, tweeted: “It’s clear Rep Ratcliffe was selected because he exhibited blind loyalty to @realDonaldTrump with his demagogic questioning of Mueller. If Senate Republicans elevate such a partisan player to a position requiring intelligence expertise & non-partisanship, it’d be a big mistake.”