WASHINGTON — President Trump announced on Sunday that Dan Coats would step down as the director of national intelligence after a fraught tenure marked by tension with the Oval Office, and he tapped one of his staunch defenders, Representative John Ratcliffe, to take over the country’s expansive network of spy agencies.

Mr. Coats, a former senator and longtime pillar of the Republican establishment who angered the president by providing unwelcome assessments of Russia, North Korea and other matters, told Mr. Trump last week that it was time to move on, officials said. His departure removes one of the most prominent national security officials willing to contradict the president.

If Mr. Ratcliffe is confirmed by the Senate, he will offer a starkly different perspective in the Situation Room, one more in line with Mr. Trump’s thinking. Mr. Ratcliffe, a third-term Republican from Texas and a former prosecutor, has embraced Mr. Trump’s theories about the Russia investigation and was among the sharpest questioners of Robert S. Mueller III, the former special counsel, at last week’s hearings.

Mr. Trump met with Mr. Ratcliffe on July 19 to discuss the job, but the hearings just five days later offered the congressman a chance to essentially audition for the president, who enjoyed watching him grill Mr. Mueller, according to people informed about the process.