WASHINGTON (Reuters) - Differences over how to deal with North Korea’s nuclear challenge were a key factor in President Donald Trump’s decision to replace Rex Tillerson as U.S. secretary of state, according to sources familiar with the internal deliberations.

Tillerson had been an early advocate of talks with North Korea to the annoyance of Trump, who wanted to keep applying maximum pressure on Pyongyang before responding to an invitation to meet North Korean leader Kim Jong Un, the sources said.

That had led to fear that Tillerson might be too willing to make concessions to North Korea, the sources said.

“He’s got to have somebody in there that he totally trusts,” said a senior U.S. official.

In recent weeks Trump spent time putting in place a succession plan, lining up Central Intelligence Agency Director Mike Pompeo to take over at the State Department and CIA deputy director Gina Haspel to replace Pompeo as the head of the spy agency, the source said.

A key aim was to get the team in place prior to moving ahead with North Korea.

Trump and Kim have committed to meeting at a time and place to be determined before the end of May to discuss North Korea’s nuclear and ballistic missile programs.

In a snub, Tillerson was left out of the loop regarding the North Korean invitation and was on his first trip to Africa when Trump sat down at the White House with a visiting delegation from South Korea last Thursday and agreed to meet Kim.

The next day, Friday, Trump told White House Chief of Staff John Kelly to tell Tillerson he needed to resign, White House officials said.

One source said Kelly had been trying to protect Tillerson as long as he could, but that Trump had grown weary of Tillerson’s tendency to contradict the president on a variety of issues and had been telling friends he was about to dump him.

Tillerson, who was in Nairobi at the time and still had two stops to go - Chad and Nigeria - asked that he first return to the United States before it was announced.

Hours after Tillerson landed in Washington on Tuesday, Trump announced on Twitter that he was being dismissed and replaced by Pompeo.

State Department officials said Tillerson did not know why he was being pushed out. One of them, Steve Goldstein, was fired later on Tuesday after he contradicted the White House’s version.

Tillerson, whose tenure ends on March 31, returned to the State Department on Wednesday to hand over responsibilities to John Sullivan, his deputy, and to meet with senior officials, a State Department official said.

The official said Tillerson’s chief of staff, Margaret Peterlin, and deputy chief of staff, Christine Ciccone, had resigned.

It was not immediately clear whether Tillerson’s policy chief, Brian Hook, would stay on beyond March 31. The department announced on Wednesday that Hook would travel to Vienna to participate in a meeting on Friday on the Iran nuclear deal.