As the White House absorbed the news about Mr. Tillerson, rumors swirled that the national security adviser, Lt. Gen. H. R. McMaster, and the secretary of Veterans Affairs, David J. Shulkin, would soon follow him out the door. The sense of disarray was deepened by the purging of Mr. Tillerson’s inner circle and the sudden dismissal of a personal aide to Mr. Trump.

“I’m really at a point where we’re getting very close to having the cabinet and other things I want,” Mr. Trump said Tuesday before leaving for a trip to California. He said he disagreed with Mr. Tillerson on the Iran nuclear deal and on other issues.

“It was a different mind-set,” Mr. Trump said.

Their lack of rapport was evident in the peremptory way the president fired him. Mr. Tillerson learned of it on Tuesday morning when an aide showed him a Twitter post from Mr. Trump announcing the change. But he had gotten a warning last Friday when the chief of staff, John F. Kelly, called to tell him to cut short a trip to Africa and added, “You may get a tweet.”

It was an abrupt end after months of speculation — to a star-crossed tenure for a Texas oil baron who never adapted to the power dynamics of Mr. Trump’s world, or to the president’s worldview. Mr. Tillerson clashed with the White House staff and broke with Mr. Trump on a range of issues, including the dispute between Saudi Arabia and Qatar and the American response to Russia’s cyberaggression.

However sudden his departure, Mr. Tillerson’s future had seemed tenuous since reports last October that he called Mr. Trump a “moron” in a meeting with colleagues at the Pentagon. Mr. Trump, aides said, never forgave him.