Receive the latest national-international updates in your inbox

In a written farewell message, Mattis urged all employees to "keep the faith in our country and hold fast, alongside our allies, aligned against our foes."

Jim Mattis ended one of history's more turbulent tenures as defense secretary on Monday by re-emphasizing a key difference with President Donald Trump and encouraging Pentagon employees, civilian and military, to "hold fast" in safeguarding the nation.

Mattis, who submitted his resignation on Dec. 20 and was, in effect, fired by Trump three days later, spent the day in his third-floor Pentagon office preparing to hand off his duties at midnight to Deputy Secretary Patrick Shanahan. Shanahan, a former Boeing executive, will be acting defense secretary until someone is nominated for the post.

In a written farewell message, Mattis urged all employees to "keep the faith in our country and hold fast, alongside our allies, aligned against our foes." Mattis sees allies, including NATO, Japan and South Korea, as central to U.S. foreign and security policy, a point on which he differed from Trump, who denigrated allies as unworthy freeloaders.

In 711 days as defense secretary, Mattis wrestled with a series of surprise, sometimes sudden and often confusing, decisions by Trump, including a July 2017 presidential tweet saying he would ban transgender people from serving in the military. Mattis also disagreed with Trump's withdrawal from the Iran nuclear deal. He counted as a victory his persuading Trump to abandon, at least temporarily, his stated instinct to withdraw from Afghanistan. Earlier this month, Trump reversed himself and ordered a partial withdrawal, overriding Mattis' objections.

Trump Shutdown Proposal Said to Be a 'Non-Starter'

Democratic leaders and even some Republicans say they can't support President Donald Trump's offer to extend limited protections to undocumented immigrants in exchange for border wall funding and an end to the government shutdown.

(Published Monday, Jan. 21, 2019)

Mattis also was set back by Trump's tweet Dec. 8 announcing he had picked the Army chief of staff, Gen. Mark Milley, to be the next chairman of the Joint Chiefs of Staff. This not only left the current chairman, Gen. Joseph Dunford, in a lame duck status until his scheduled retirement next fall, but it also marked an unusual rejection of advice from his own secretary of defense. Mattis had recommended Air Force Gen. David Goldfein for the job.

The disagreements accumulated, and when Trump decided to pull U.S. troops out of Syria, Mattis submitted a resignation letter he had written some days earlier. His decision to quit stunned many in the Pentagon and around the world. Trump himself seemed taken aback, and three days later, he tweeted that Shanahan would replace Mattis on Jan. 1, cutting short Mattis' announced plan to stay until Feb. 28 to ensure a smooth transition.

When he announced Mattis as his choice to lead the Pentagon shortly after his November 2016 election victory, Trump referred to him by his nickname, "Mad Dog," suggesting he valued an unpredictable, intimidating approach to defense policy. This turned out not to match the Mattis style, which emphasized respectful collaboration with allies and partners.

In his farewell note, Mattis quoted a one-sentence telegram that President Abraham Lincoln sent to the commander of Union forces, Gen. Ulysses S. Grant, on Feb. 1, 1865, in the final weeks of the Civil War. It said: "Let nothing which is transpiring, change, hinder, or delay your military movements, or plans." On that date, Lincoln signed a joint congressional resolution proposing a constitutional amendment to abolish slavery.

Mattis said he's confident Pentagon employees will remain "undistracted from our sworn mission to support and defend the Constitution while protecting our way of life."

Mattis has not said publicly what he intends to do next. He has mused about returning to his roots in Washington state. He was born in Pullman and raised in Richland. He graduated from Central Washington University in 1971 and then entered the Marine Corps, where he began as a second lieutenant and rose to the rank of four-star general.

Mattis is the first retired general to serve as defense secretary since George Marshall in 1950-51. His confirmation by the Senate required passage of legislation overriding a prohibition against former U.S. service members who have been out of uniform fewer than seven years from holding the Defense Department's top job. Mattis retired from the Marines in 2013.

David Maxwell, a retired Army colonel who served 30 years in uniform, said the farewell and resignation letters together will "be studied and examined ... for years to come" for lessons in leadership. Maxwell is a senior fellow at the Foundation for the Defense of Democracies.

Mattis, 68, has not publicly commented on his reasons for resigning, beyond what he wrote in his resignation letter, in which he expressed pride at having served with the men and women of the Defense Department but did not directly thank Trump. He wrote that the president has "the right to have a secretary of defense whose views are better aligned with" his.

"My views on treating allies with respect and also being clear-eyed about both malign actors and strategic competitors are strongly held and informed by over four decades of immersion in these issues," Mattis wrote.

Shanahan, who has been the Pentagon's No. 2 official since July 19, 2017, had worked for Boeing Co. since 1986. His views on strategic issues such as U.S. alliances and the wars in Afghanistan and Syria are largely unknown to the public. During his Senate confirmation hearing in June 2017, he drew the ire of Republican Sen. John McCain of Arizona for equivocating on whether he favored providing defensive weaponry to Ukraine in response to Russian military intervention.

Although he will have the title of acting secretary, Shanahan will hold all the executive and command authorities of a Senate-confirmed secretary, according to his spokesman, Army Lt. Col. Joe Buccino. It is rare for the Pentagon to be run by an acting secretary; the last was William H. Taft, who served in that capacity for about 60 days in 1989 after President George H.W. Bush's initial choice to be defense secretary, John Tower, became mired in controversy and ultimately failed to be confirmed by the Senate. Dick Cheney then was nominated and confirmed.

Shutdown, Russia Woes Grow for Trump

President Trump lashed out at House Speaker Nancy Pelosi amid the ongoing government shutdown and more troubling revelations about the 2016 election. NBC's Tracie Potts reports.