(CNN) President Donald Trump announced Tuesday that he has fired Secretary of State Rex Tillerson and will nominate CIA Director Mike Pompeo to succeed him, replacing his top diplomat ahead of a potential high-stakes sitdown between the US President and North Korean leader Kim Jong Un.

Tillerson's departure follows months of tension between him and Trump. Gina Haspel, the current CIA deputy director, stands to take over the agency, Trump tweeted Tuesday morning.

Mike Pompeo, Director of the CIA, will become our new Secretary of State. He will do a fantastic job! Thank you to Rex Tillerson for his service! Gina Haspel will become the new Director of the CIA, and the first woman so chosen. Congratulations to all!

Speaking to reporters at the White House, Trump said he respected Tillerson's "intellect" and said he "got along well with Rex."

"I think Rex will be much happier now," Trump said.

Tillerson thanked the American people, his State Department staff and the nation's extensive network of diplomats in his farewell statement on Tuesday.

One person he did not thank: Trump, the man who nominated him for the job but abruptly told the world of his ouster in a tweet on Tuesday morning.

The only mention of Trump came at the top of the statement when Tillerson mentioned that the President called him "a little after noontime from Air Force One" to talk about his ouster. That call came hours after Trump told the world Tillerson was fired on Twitter.

Trump "thought it was the right time for the transition with the upcoming North Korea talks and various trade negotiations," a senior administration official said, adding that Trump asked Tillerson to step aside on Friday. A senior White House official later clarified that chief of staff John Kelly told Tillerson that he would be replaced, but did not specify the timing.

Earlier on Tuesday, Undersecretary for Public Diplomacy Steve Goldstein said Tillerson had not spoken to Trump and was unaware of the reason behind his firing.

Goldstein said Tillerson was notified of the official termination in Trump's tweet Tuesday morning and, in a statement, said Tillerson had "every intention of remaining." Hours after the statement was released, Goldstein himself was fired.

Asked how Tillerson learned of his dismissal, Trump said Tuesday that "Rex and I have been talking about this a long time." He specifically mentioned the Iran nuclear deal as an example of disagreement.

"We were not really thinking the same," Trump said. "With Mike Pompeo, we have a similar thought process."

JUST WATCHED Trump: Tillerson and I didn't think the same Replay More Videos ... MUST WATCH Trump: Tillerson and I didn't think the same 03:06

Trump eyed Pompeo for months

Trump has wanted Pompeo as his secretary of state for months now, and the White House began planning for him to take the job last fall, sources told CNN. Trump told reporters Tuesday that he and Pompeo are "on the same wavelength" and "the relationship has always been very good and that is what I need."

Trump's anger at Tillerson after it leaked last year that his secretary of state called him "a moron" never subsided, and many in the White House saw their differences as irreconcilable.

Tillerson had few, if any, allies in the West Wing. Though Kelly was initially on his side when he took over, he eventually grew weary of defending him -- especially after the "moron" remark, which Kelly saw as insubordination on Tillerson's part.

Sources close to the President say it was clear Tillerson didn't support Trump. They say Tillerson wanted to handle foreign policy his own way, without the President. Trump didn't feel that Tillerson backed him, a source told CNN.

Trump and his top aides have spent recent days attempting to quell talk of a White House in chaos, with the President tweeting earlier this month that there was "no Chaos, only great Energy" in the White House. But five top Trump administration officials -- ranging from communications professionals to Tillerson -- have resigned or been fired in the last two weeks.

JUST WATCHED Tillerson: Trump tweets don't change policy Replay More Videos ... MUST WATCH Tillerson: Trump tweets don't change policy 00:53

High-stakes moment

Tillerson's departure comes just as the Trump administration embarks on its most difficult and ambitious foreign policy goal to date -- engaging the nuclear armed North Korean regime. Trump is set to meet Kim by the end of May.

Tillerson had spearheaded the maximum pressure campaign that the administration credits with bringing the North Koreans to the negotiating table, bringing the issue up in every country meeting he had, no matter how seemingly unrelated.

Two people familiar with the matter say the North Korea issue was the single biggest factor in the ousting of Tillerson. Trump told aides that differences over how and when to hold talks with Kim only underscored what he's felt for months, which is that Tillerson is just on a different wavelength.

Another source close to the White House said Trump "wanted a strong team ready for North Korea. That's why he moved the chess pieces."

Trump discussed not having talked about the North Korea decision with Tillerson Tuesday morning while departing the White House.

On a recent flight back from Africa, Tillerson spoke with reporters off camera, and seemed almost to lobby for his ability to continue the job.

"I have a lot of confidence in my ability to create the conditions for successful negotiations between two very disparate parties," Tillerson said, adding that he and others were working to prepare Trump to deal with Kim. "But I'm not the only guy working on this. Others are working on this as well. We have an obligation to prepare the President for that meeting and I think there is some ground work we can do ahead of that that will help with that preparation."

JUST WATCHED Trump and Tillerson's tense relationship Replay More Videos ... MUST WATCH Trump and Tillerson's tense relationship 01:50

Rocky tenure

It was a rocky tenure for Tillerson. Since his swearing in on February 1, 2017, Tillerson had to contend with a President who publicly undercut him as well as tension with Trump son-in-law Jared Kushner, who effectively ran a shadow State Department on Middle East issues. There was also competition from US Ambassador to the UN Nikki Haley and a litany of complaints from diplomats, State Department staff and others in Washington that he was running a deeply dysfunctional agency.

Tillerson's cost cutting has lead to the agency's senior tiers "being depleted at a dizzying speed," and "a decapitation of its leadership ranks," Amb. Barbara Stephenson, president of the American Foreign Service Association (AFSA), a union for US foreign service personnel, wrote in her group's publication.

"There is simply no denying the warning signs that point to mounting threats to our institution -- and to the global leadership that depends on us," Stephenson wrote.

Tillerson aggressively pushed back against such criticisms in a November 28 appearance, portraying it as an insult to State Department staff. "I'm offended on their behalf when people say somehow we don't have a State Department that functions," Tillerson said. "I can tell you it's functioning very well from my perspective."

But a steady drip of negative news, and reports of Tillerson's alleged resentment over Ivanka Trump leading a delegation to the Global Entrepreneurship Summit in India in November, continued to undermine Tillerson.

His ouster was preceded by a painfully public airing of his troubles with the President, heightened when Sen. Bob Corker, the Tennessee Republican who chairs the Senate Foreign Relations committe, faulted Trump for his tendency to "publicly castrate" the secretary of state. That exchange forced Tillerson, when asked about the comment by CNN's Jake Tapper , to declare, "I checked. I'm fully intact."

By that point, in mid-October, an administration official was telling CNN that Tillerson was on thin ice, even as the President was publicly declaring he had confidence in his top diplomat.

The castration episode followed an extraordinary October 4 public statement in which Tillerson stressed his commitment to his job as secretary of state, but didn't definitively deny an NBC report that he had called Trump a "moron."

That report also detailed Tillerson's "fury" about the ways Trump has undermined him publicly on several foreign policy initiatives and his thoughts about resigning.

Calling the story "erroneous" during his remarks, Tillerson pointed the finger at "some who try to sow dissension" to undermine the President's agenda and said he has been asked "repeatedly" if he's going to step down.

"For some reason, it continues to be misreported," Tillerson complained. "There's never been a consideration in my mind."

The incident cost Tillerson the support of Kelly, a top White House official told CNN.

Kelly, a retired four-star Marine general who was once Tillerson's fiercest defender in the West Wing, stopped defending him privately, fed up with the moron remark because he saw it as insubordination. As one official described it, he had grown weary of trying to defend the indefensible.

Even as Tillerson lost support in the White House, some lawmakers expressed concern about the prospect of his departure. Many saw Tillerson, along with Defense Secretary James Mattis and national security adviser H. R. McMaster, as a serious defender of US national security interests, as opposed to more ideological or inexperienced voices in the White House.

Difficult situation for Tillerson

As Tillerson exits the national stage, he's seen by some as a man who tackled a job he hadn't sought with the diligence and dedication prized by another organization he led, the Boy Scouts of America. Many point to the fact that he was in a situation that made it very difficult to succeed.

Tillerson started the job diverging with Trump on any number of issues, from trade, climate change, Russian interference in the 2016 election and Iran policy. And he encountered headwinds from the President who publicly contradicted or undermined his policies on using diplomacy to defuse tensions with North Korea, and on resolving a dispute between Gulf allies and a host of other issues.

Others have dismissed Tillerson's tenure, saying his business experience hadn't translated into government leadership and pointing to the downsized and demoralized State Department he leaves behind, with many senior diplomatic positions still unfilled.

Critics from both parties said his proposed cuts of up to 30% were damaging US interests, with former Secretary of State Madeleine Albright declaring in November that the state of the agency was a "national security emergency."

Foreign envoys also voiced concerns about Tillerson's State Department. In October, one Washington-based envoy described how ambassadors were finding ways to either bypass the State Department or develop work-arounds, because there were no senior officials in place to speak to or because the usual channels within State no longer worked.

"Technically, the State Department has vanished, has disappeared," the envoy said. "It's totally dysfunctional."