UPDATE: President Donald Trump announced Tuesday morning that he had fired Secretary of State Rex Tillerson, replacing him with CIA Director Mike Pompeo and ending months of speculation about how much longer the embattled secretary of state could last in that role.

In a tweet, Trump thanked Tillerson for his service and said Pompeo "will do a fantastic job."

The ouster ends months of discord between Trump and Tillerson, who often seemed out of the loop or in disagreement with the president on major foreign policy decisions. The president also named Gina Haspel as the new head of the CIA, pending the confirmation process. Those hearings are expected to dredge up debates about controversial interrogation tactics, like waterboarding, that might make her path to permanence a rocky one.

Trump's firing of Tillerson was just the most recent of many slights suffered by the former businessman-turned-top diplomat at the hands of his boss: a senior State Department official told NBC that Tillerson officially found out that he had been fired when Trump tweeted the news that he'd been replaced.

The exit was not a voluntary one, the State Department confirmed in a startling statement Tuesday. Tillerson "did not speak to the President and is unaware of the reason" for his firing, Under Secretary of State Steve Goldstein said in a statement Tuesday morning, "but he is grateful for the opportunity to serve."

Hours after Goldstein's statement contradicting the White House's account on Tillerson, a senior State Department official confirmed to NBC News that he had also been fired. In a statement to NBC News after his dismissal, Goldstein said he was "proud to speak on behalf of the Secretary of state to the American people and allies throughout the world and this has been the honor of a lifetime."

The White House and Foggy Bottom issued competing accounts Tuesday of the details of Tillerson's firing.

NBC News learned Tuesday from sources familiar with the situation that Chief of Staff John Kelly spoke with Tillerson by phone on Friday and told him that Trump intended to ask him to “step aside." In that call — which came while Tillerson was traveling through Africa — Kelly did not specify when that change might come. Kelly also called Tillerson again on Saturday, a senior White House official said, expressing once again the president's "imminent" intention to replace his secretary of state.

The Associated Press, citing senior State Department officials, reported Tuesday that Tillerson had been even more blindsided, saying that Kelly had warned him on that Friday call that there might be a tweet from the president coming that would concern him, but did not detail what the tweet might say or when it would post.

Tillerson, said Goldstein, had "every intention of staying because of the critical progress made in national security."

It's not the first time the president has opted for an indirect approach to firing government aides, avoiding face-to-face confrontation despite being well-known for his willingness to say "you're fired" on national television to contestants on his reality show. His surprise dismissal of former FBI Director James Comey came while Comey was out of town in California, and his tweet announcing the departure of former Chief of Staff Reince Priebus came while Trump was on Air Force One. Priebus was left on the tarmac at Andrews Air Force Base when the plane landed, after the news was out.

On the South Lawn Tuesday, Trump told reporters he was “close” to having the Cabinet he wanted, wishing Tillerson well while predicting “great” things from Pompeo in the State Department role.

"Rex and I have been talking about this for a long time," the president said before boarding Marine One to head to California. While the two got along "well," said Trump, "we disagreed on things."

"We were not really thinking the same," Trump said of Tillerson. "With Mike [Pompeo]...we have a very similar thought process. I think it's gonna go very well."

As for Tillerson, Trump thinks he "will be much happier now."

The secretary of state is just the latest in a string of high profile departures from the Trump administration in the past month. Longtime Trump confidante and Communications Director Hope Hicks resigned at the end of February, while top economic advisor Gary Cohn announced he would depart the administration last week.

Though Tillerson's firing dominated headlines early Tuesday, it emerged that Trump campaign original John McEntee — the president's longtime personal assistant — had also left the administration. McEntee will take on a senior role within the Trump campaign after abruptly exiting his White House job this week.

While Trump says he's close to getting the Cabinet he wants, more departures could soon come. NBC reported earlier this month that National Security Advisor H.R. McMaster would likely be out of his job by the end of March, with the White House pushing back on the story.

Pompeo, who will be nominated to succeed Tillerson, may face a tough confirmation process in the Senate.

While Tillerson — who took a more traditional approach to his job as America's top diplomat — clashed with Trump throughout his tenure, Pompeo has enjoyed a much closer relationship with the president. Multiple current and former intelligence officials told NBC last year that some inside the intelligence community started calling Pompeo the “Trump whisperer,” referencing the depth of the relationship between the two.

Tillerson spent the past week on a lengthy trip through Africa, landing very early Tuesday morning in Washington after cutting his trip short by one day.

His Africa trip highlighted even more daylight between Tillerson and his boss, most recently on North Korea, as well as the poisoning of a Russian spy last week.

While the White House on Monday refused to sign on to the British assessments that Russia was responsible for the attempted poisoning of an ex-spy in the U.K., Tillerson told press aboard his government aircraft that the “really egregious act” appears to have “clearly” come from Russia.

The coming meeting with North Korea’s Kim Jong Un also played a role, a senior administration official told NBC News, saying that Trump “wanted to make sure to have his new team in place in advance of the upcoming talks with North Korea and various ongoing trade negotiations.” Trump said Tuesday that he made the decision to speak with Kim by himself.

Just one day before Trump agreed to meetings with Pyongyang last week, Tillerson — during a trip in Africa — said the two countries were still “a long way” from direct negotiations with the regime about their nuclear program.

Though the timing of the ouster came as a surprise, the move itself was not a shock following months of rumors.

A White House official told NBC News in December of last year that the administration was considering a plan to replace Tillerson with Pompeo. At the time, that official said Tillerson’s allies within the administration had grown scarce — “he’d burned all his bridges,” this person said on condition of anonymity.

The tension between Tillerson and Trump was heightened following NBC News reporting that the former Exxon Mobile mogul openly disparaged the president after a July 20, 2017 meeting at the Pentagon, referring to him as a “moron, according to three officials familiar with the incident.

The next battlefront on the horizon for the White House may not be an internal one: Pompeo and Haspel will head to the Hill for confirmation to their new positions.

Former CIA Director and NBC analyst John Brennan predicted "close scrutiny" of Haspel's nomination given her years of work at the agency, including time spent running a prison in Thailand that waterboarded and used rough interrogation tactics on terror suspects — a practice Trump has voiced support for in the past.

And Pompeo's past comments on Russia, which have often echoed his boss's less-critical take, are also certain to be a central line of questioning for Republicans and Democrats alike during any future hearings.

For now, the nomination earned Trump praise from some supportive senators. Tom Cotton, R-Ark., issued a supportive statement almost immediately after the announcement. NBC had been told last year that the administration was considering Cotton for the top spot at CIA.

A source close to Cotton told NBC Tuesday he was aware of the shakeup before the president's tweet this morning, giving him more notice than most of his fellow senators — and even the secretary of state himself.