James Mattis’ resignation letter laid bare the frightening future of national security under President Trump.

The defense secretary made clear he could no longer serve a president who betrays our friends and bows to our adversaries. The last straw was Trump’s green light to Turkey to massacre our Syrian Kurdish allies.

But what finally drove Mattis out was not just Trump’s callous indifference toward America’s friends. It was also the way Trump has turned foreign policy-making into a one-man show based on personal whim — or self-aggrandizement.

The last significant foreign policy brake on the self-styled “genius” in the White House will now be gone. Americans better hunker down for 2019 — because Trump’s stunning decision on Syria highlights every dangerous component of his policy-making approach.

Consider them one by one:

Trump’s foreign policy process has become so chaotic it is almost nonexistent. Trump suddenly tweeted the news that 2,000 U.S. forces would leave Syria within weeks without prior consultation with any of his team — not the Pentagon, not his secretary of state, not his national security adviser, not his commanders, not Congress, not NATO allies fighting alongside us in Syria, not the Kurds.

In the preceding weeks, almost every top Trump adviser on Syria — both military and civilian — had been stating publicly that those troops would be staying for some time to prevent an ISIS revival or further advances by Iran. Syrian Kurds had also been recently reassured.

Just last week, the U.S. special envoy to the anti-ISIS coalition, Brett McGurk, told reporters: “Americans will remain on the ground after the physical defeat of the [ISIS] caliphate, until we have the pieces in place to ensure that that defeat is enduring. Nobody is declaring a mission accomplished.”

From Mattis on down, all of these U.S. officials were blindsided by Trump’s tweet. As were the Kurds.

Trump’s foreign policy decisions appear driven more by personal issues than security concerns. In a video defending his Syria decision, Trump declared, “We have won against ISIS.” Not true.

There are an estimated 20,000 to 30,000 ISIS fighters believed to be laying low in Syria and Iraq, who could re-emerge if U.S. troops leave prematurely. U.S. special forces — while small in numbers — give Kurds and Sunni tribesmen the confidence to keep fighting, while training them to take over after a future U.S. exit. They also gather intelligence on the growing Iranian presence in Syria.

Those U.S. troops provide Washington with its main leverage in ongoing international negotiations over Syria’s political future, preparing the ground for U.S. troops to ultimately leave. Trump’s move has cut the legs out from U.S. negotiators.

So why did Trump tweet now? No sign security interests were considered.

It’s possible that the unusual criticism he took last week from far-right Fox News commentators about the border wall convinced Trump he needed to fulfill a different campaign promise and bring the troops home. Or — since Trump shows little interest in long-term strategic thinking, and views every foreign policy issue in terms of making the best monetary deal — his phone conversation last week with Turkish President Recep Tayyip Erdogan may hold the key. The two leaders discussed new arms deals — a quid pro quo for letting Turkey crush the Kurds?

Which brings us to the third component: Trump emboldens autocrats while betraying allies. The president kowtowed to the despotic Erdogan, despite Turkey’s pledge to bury the Kurds. The Turks have already bombed the Kurdish Afrin region of Syria.

Moreover, those who will gain most from the U.S. withdrawal, besides Erdogan, are Russia’s Vladimir Putin and Iran’s ayatollahs, whose hold on Syria will be solidified after a total U.S. exit. Putin swiftly praised Trump’s decision to quit Syria. (Mattis has long been disturbed by Trump’s attraction to the Russian leader).

Those who will lose most are America’s Sunni allies in the region and Israel, which will face an emboldened Iran across its border with Syria (the Israeli press has been scathing about Trump’s decision). America’s NATO allies, some fighting with us in Syria, are also alarmed.

And, of course, the the Kurds, who face Turkish slaughter from the skies, are stunned. It was Trump’s indifference to their fate that reportedly propelled Mattis to quit. He also knows Trump’s betrayal will discourage any putative allies from working with the United States in the future.

And so, the retired Marine general reached his limit. (He also opposed another sudden Trump order this week for half of the 14,000 U.S. troops in Afghanistan to return home, undercutting new U.S. efforts to negotiate a deal between Afghan leaders and the Taliban.)

But Mattis’ stand won’t curb Trump unless the retired Marine general speaks out publicly. And unless, a critical mass of GOP senators finally recognizes the danger of an unrestrained Trump and confront him.

“If Obama had done this,” said Sen. Lindsay Graham (R., S.C.) about the GOP response to the Syria decision, “we’d be going nuts right now; how weak, how dangerous.” Enough said.