The tension between Tillerson and Trump required and intervention from Pence.

1280x720_70428P00-DCBNA _OP_1_CP__1507128746285_27261404_ver1.0_640_360.jpg

WASHINGTON — Secretary of State Rex Tillerson was on the verge of resigning this past summer amid mounting policy disputes and clashes with the White House, according to senior administration officials who were aware of the situation at the time.

The tensions came to a head around the time President Donald Trump delivered a politicized speech in late July to the Boy Scouts of America, an organization Tillerson once led, the officials said.

Just days earlier, Tillerson had openly disparaged the president, referring to him as a “moron,” after a July 20 meeting at the Pentagon with members of Trump’s national security team and Cabinet officials, according to three officials familiar with the incident.

In an unscheduled statement to reporters Wednesday morning, Tillerson directly addressed that version of events, saying, "I have never considered leaving this post."

He praised Trump's foreign policy agenda, saying he was part of a team to "make America great again." But he did not deny calling the president a "moron," declining to address that remark directly and saying, "I'm not going to deal with petty stuff like that."

In a briefing Wednesday afternoon, State Department spokesperson Heather Nauert said Tillerson did not use the word "moron" to descibe the president. "The secretary did not use that type of language to speak about the president of the Unites States," Nauert said. "He did not say that."

The president was asked about Tillerson's remarks after touring the University Medical Center in Las Vegas Wednesday and said, "I am very honored by him comments, it was fake news, it was a totally phony story." Trump added that he has "total confidence in Rex."

While it's unclear if he was aware of the incident at the Pentagon, officials said Vice President Mike Pence counseled Tillerson, who is fourth in line to the presidency, on ways to ease tensions with Trump, and other top administration officials urged him to remain in the job at least until the end of the year.

Officials said that the administration, beset then by a series of high-level firings and resignations, would have struggled to manage the fallout from a Cabinet secretary of his stature departing within the first year of Trump’s presidency.

Pence has since spoken to Tillerson about being respectful of the president in meetings and in public, urging that any disagreements be sorted out privately, a White House official said. The official said progress has since been made.

Yet the disputes have not abated. This weekend, tensions spilled out into the open once again when the president seemed to publicly chide Tillerson on his handling of the crisis with North Korea.

NBC News spoke with a dozen current and former senior administration officials for this article, as well as others who are close to the president.

Tillerson, who was in Texas for his son’s wedding in late July when Trump addressed the Boy Scouts, had threatened not to return to Washington, according to three people with direct knowledge of the threats. His discussions with retired Gen. John Kelly, who would soon be named Trump’s second chief of staff, and Defense Secretary James Mattis, helped initially to reassure him, four people with direct knowledge of the exchanges said.

Source: nbcnews.com