The relationship was further eroded when it was reported that last summer he called the president a “moron” at a gathering of national security and cabinet officials and, after Mr. Trump spoke respectfully of white nationalists who demonstrated in Charlottesville, Va., Mr. Tillerson said Mr. Trump “speaks for himself.”

So the president announced he would replace Mr. Tillerson with Mike Pompeo, the C.I.A. director and former Tea Party congressman, who has endeared himself to Mr. Trump with his engaging approach during morning intelligence briefings. Mr. Pompeo has also endeared himself to the climate-denying Koch brothers, who, along with their family, employees and affiliated groups donated $357,300 to his campaigns and political action committee, according to the McClatchy newspapers. Mr. Pompeo is unlikely to be sidelined in major policy debates, as Mr. Tillerson was regularly, even though he too, unlike Mr. Trump, supported his agency’s conclusion that the Kremlin interfered in the 2016 elections. But his hawkish approach could do serious damage on major national security issues, including Iran and North Korea, on which he has expressed views at odds with his predecessor’s.

The timing of Mr. Tillerson’s ouster most likely hinges on the fact that Mr. Trump is facing his biggest foreign policy gamble, a decision to hold direct negotiations over North Korea’s nuclear weapons program, starting with face-to-face talks with the country’s leader, Kim Jong-un, supposedly in May. Tough trade talks are also looming.

Mr. Trump and Mr. Kim are expected to set the stage for negotiations and then let senior teams for the two sides do the detail work, which is likely to take months if not years. Before the shakeup, it was assumed Mr. Tillerson would lead the American team — one hobbled by a lack of North Korea expertise. Now, that role is likely to be filled by Mr. Pompeo, who has effectively pushed for regime change in North Korea and even alluded to assassinating Mr. Kim.

Mr. Pompeo will face other challenges in managing an increasingly aggressive China, as well as dealing with Europe and Afghanistan and turmoil in Syria and other parts of the Middle East.