The extraordinary resignation letter that Defense Secretary Jim Mattis handed to a surprised President Donald Trump was not just a product of two years of accumulating frustration with an impulsive boss, but an outline of the strategic hazards facing the next Pentagon chief.

Mattis, who was quietly back at work Friday while stunned Pentagon staff soldiered on around him, implicitly warned in his letter to the president of the threat to the U.S. from allowing alliances to fray and of the risk that disrespecting allies will undermine U.S. credibility.

It was an outline of the challenges facing the nation and whoever takes over as defense secretary when Mattis leaves Feb. 28.

"As this Administration continues to implode, Secretary Mattis' extraordinary resignation is a significant loss and a real indication that President Trump's foreign policy agenda has failed and continues to spiral into chaos," said Sen. Bob Menendez, the ranking Democrat on the Foreign Relations Committee.

Mattis announced on Thursday his plan to resign, a move prompted by the decision by the president to pull all of the approximately 2,000 U.S. troops from the fight against the Islamic State group in northeastern Syria.

Mattis also was dismayed by plans under consideration to cut the number of U.S. troops in Afghanistan and, as his letter made clear, did not see eye to eye with a president who has expressed disdain for NATO and doubts about keeping troops in Asia.

The person nominated to succeed Mattis will face a Senate likely to probe for evidence of new strategic direction in hotspots like Syria, Afghanistan and the Korean peninsula.

In making clear that he could no longer tolerate Trump's approach to American foreign policy, Mattis appeared to fashion a resignation letter that not only expressed his reasons for leaving but also sounded an alarm. He implicitly criticized the president's unwillingness to stand up to Russia or take a stronger stance against Chinese assertiveness.

"I believe we must be resolute and unambiguous in our approach to those countries whose strategic interests are increasingly in tension with ours," Mattis wrote. "It is clear that China and Russia, for example, want to shape a world consistent with their authoritative model ... to promote their own interests at the expense of their neighbors, America and our allies."

Nurturing and extending U.S. alliances was a pillar of Mattis' approach to his job, which means he was at odds with Trump on that score from the earliest months of his tenure.

"While the U.S. remains the indispensable nation in the free world, we cannot protect our interests or serve that role effectively without maintaining strong alliances and showing respect to those allies," Mattis wrote.

William Cohen, a former defense secretary and long-time friend of Mattis, put a finer point on this Mattis assertion by saying in response to his resignation, "He cannot be expected to stand behind a president who disrespects our allies and ingratiates himself to our adversaries."

In addition to the frayed state of U.S. relations with NATO, Mattis' successor also is likely to face other hazards hinted at in his resignation letter. These include preserving and rationalizing a strategy for ensuring a lasting defeat of the Islamic State group by the dozens of nations that had backed the U.S. after it entered Syria in 2014.

German officials expressed polite irritation that Washington had not consulted them on the Trump decision to pull out of Syria.

"As an ally and member of the anti-IS coalition we would have considered prior consultation by the U.S. government about the withdrawal of U.S. troops helpful," government spokeswoman Ulrike Demmer said.

The Pentagon was still reeling Friday from the news that Mattis was leaving.

Inside what is normally a very orderly building, military members who are trained to take orders, salute and move ahead were stunned and a bit shaken.

Military missions in Syria and Afghanistan that just a week ago seemed clear and mapped out, were now thrown into chaos. Deep in the bowels of the Pentagon, planners scrambled to pull together a troop withdrawal strategy for Syria that the White House would accept, all while knowing that their boss a few floors above them quit over that order.

Mattis, 68, is the first Pentagon chief to resign in protest over a president's foreign policy in many decades. In fact, there may be no historical equivalent to the circumstances of Mattis' departure. The last defense secretary to resign was Chuck Hagel in November 2014, and although he had expressed differences with President Barack Obama over Syria policy, Hagel was essentially pushed out by an administration that viewed him as ineffective.

Robert McNamara, who served as defense secretary for seven years over two Democratic administrations, left the Pentagon in February 1968, three months after President Lyndon Johnson announced McNamara was resigning to become president of the World Bank. McNamara differed with Johnson and the military over Vietnam war policy amid an escalating anti-war movement, but his departure was not an explicit rejection of Johnson's policies.