To the extent that President Donald Trump's approach to war and peace can be summarized in a foreign policy doctrine, culled from his past statements and tweets, it goes something like this: Never show the other side your cards. Deny the enemy a chance to go on the offense. Always put America first.

Yet in a span of barely 24 hours, Trump disregarded at least two of those three pillars with his decision to withdraw from Syria and his order to the Pentagon to draw up plans for pulling troops out of Afghanistan. And while he's long ridiculed former President Barack Obama and others for policies he said made America look weak, Trump's newfound approach bears striking similarities.

As a candidate, Trump astounded many in both parties when he repeatedly labeled Obama the "founder of ISIS" and the extremist group's "most valuable player." Pressed to concede he meant that only metaphorically, Trump was adamant that no, he meant it literally.

Behind the bombast was a military argument shared by many of Obama's critics, including some Democrats: That by ordering a hasty withdrawal from Iraq, Obama created a vacuum of power there that was exploited by al Qaida-linked extremists who ultimately formed the Islamic State group and took over wide swaths of both Iraq and Syria.

"The way he got out of Iraq — that was the founding of ISIS, okay?" Trump said in August 2016.

Since he took office, Trump's national security advisers have repeatedly argued to the president that the U.S. needed to stay in Syria to avoid repeating that same mistake, despite Trump's general inclination to wind down U.S. involvement in overseas entanglements. For a while, it worked, and Trump agreed to stay. So even his top aides were shocked when he announced he was pulling all American troops out of the country and declaring victory over ISIS, despite the continuing presence of ISIS fighters there.

We have defeated ISIS in Syria, my only reason for being there during the Trump Presidency. — Donald J. Trump (@realDonaldTrump) December 19, 2018

If Iraq was ripe ground for extremists after the U.S. withdrawal, Syria is no less vulnerable. Although ISIS has lost almost all of its territory, the country remains roiled by civil war with an ineffective, internationally-shunned government propped up by Russia that controls only part of the country to begin with. A promised Turkish military incursion to clear out U.S.-backed rebels from opposition-held territory promises only to further destabilize the area.

"It demonstrates that Trump's criticisms of Obama were pure political crass," said Joel Rubin, a former deputy assistant secretary of State in the Obama administration. "There was no driving ideological philosophy on how to actually protect America."

But James Carafano, a U.S. Army veteran and national security expert at the conservative Heritage Foundation, said if Trump has erred, it's in explaining his decision-making on foreign policy inadequately.

"His instincts are always to question the efficacy of stuff," Carafano said. "Why am I doing this?"

Within 24 hours of making his Syria announcement, word emerged that Trump had ordered the military to prepare plans for a troop withdrawal from Afghanistan, due shortly after the new year. It's unclear how many of the 14,000 troops Trump might pull from the country where the U.S. has been fighting for 17 years to prevent another extremist group — al Qaida — from using the territory to plot attacks on the U.S.

U.S. soldiers gather for a brief during a combined joint patrol rehearsal in Manbij, Syria, on Nov. 7, 2018. Spc. Zoe Garbarino / U.S. Army via AP

It's a connection that Trump, himself, has drawn in the past. Last year, in a speech announcing his new Afghanistan strategy, Trump warned that a "hasty withdrawal" from Afghanistan risked ceding ground to terrorists, "just as happened before September 11."

"We cannot repeat in Afghanistan the mistake our leaders made in Iraq," Trump said.

He had another warning, too — one he's cited repeatedly on Twitter to critique his predecessor: The United States must not telegraph to its enemies when it might leave.

"How counterproductive it is for the United States to announce in advance the dates we intend to begin or end military options," Trump said in the same speech. "America's enemies must never know our plans or believe they can wait us out."

He codified that principle in a new written strategy for Afghanistan that said the U.S. presence would be "conditions-based," rather than "time-based." The idea was that the U.S. would pull out based only on factors on the ground, such as the ability of the U.S.-backed Afghan government to govern its territory and fight the Taliban effectively.

But U.S. military officials and other experts have said the Afghan government is still not there and would likely collapse if the U.S. pulled out. It's also unclear what reason the Taliban, seeing a U.S. withdrawal on the horizon, would have to continue engaging in delicate peace talks with the U.S. that have been orchestrated by Trump’s envoy for Afghanistan reconciliation, Ambassador Zalmay Khalilzad.

To be sure, Trump has not announced publicly any withdrawal from Afghanistan, and people familiar with his deliberations tell NBC News that no final decision has been made. Still, even the news that Trump had ordered up plans for a withdrawal was being seen by the Taliban as a major victory that demonstrated the efficacy of their 17-year fight against the United States presence.

"We are close to our destination," a senior Taliban commander from Helmand province told NBC News. He added: "We proved it to the entire world that we defeated the self-proclaimed world’s lone super power."

As a candidate, Trump vowed that fighting terrorism — or "radical Islamic terrorism" — would be his top priority and portrayed his opponent, Hillary Clinton, and Obama as unwilling to confront the threat. Seth Jones of the Center for Strategic and International Studies said Trump’s moves on Syria and Afghanistan appear to be based on a false assumption that the threat is fading.

In fact, Islamist extremists are growing in number and capability, with Syria at the epicenter of the danger, according to a report on global terrorism by Jones and five other experts released last month. After Syria, Afghanistan ranks second among countries with the highest number of Salafist jihadist fighters, according to the CSIS report. An estimated 43,650 to 70,550 fighters are based in Syria, and 27,000 to 64,060 are in Afghanistan, the report said.

The CSIS report, written before Trump's surprise moves this week in Syria and Afghanistan, also warned that scaling back U.S. force levels in the Middle East and Africa could give more breathing room to terrorist networks.

Husain Haqqani, Pakistan’s former ambassador to Washington, said Trump’s moves in Syria and Afghanistan were sending the message globally that the U.S" no longer considers the jihadi threat a serious threat."

"It will come back to bite the U.S.," Haqqani said.

In both Afghanistan and Syria, a smaller U.S. presence also risks creating more room for Trump’s No. 1 geopolitical foe — Iran — to expand its influence. Iranian-backed Hezbollah forces have become a major player in Syria and are viewed as a growing threat by neighboring Israel. Iran has also flexed its military and diplomatic muscle in Afghanistan, which shares a border with Iran, and has been frequently accused of surreptitiously aiding the Taliban there.

In his White House campaign, Trump had bashed Obama over Iran, calling the nuclear agreement between Tehran and world powers the "worst deal ever." He accused Obama of putting Tehran "in a dominant position of regional power and, in fact, aspiring to be a dominant world power."

Yet Trump’s decision to pull the plug on U.S. forces in Syria has handed a major victory to Iran, removing a counterweight to Tehran’s proxy forces on the ground and undercutting Washington’s leverage in any peace negotiations, according to Republican lawmakers, former U.S. officials and military officers.

Hawks that have castigated Obama over his approach to Iran expressed outrage and disappointment over Trump’s troop withdrawal Syria and planned drawdown in Afghanistan.

"If we continue on our present course we are setting in motion the loss of all our gains and paving the way toward a second 9/11," said Republican Sen. Lindsey Graham of South Carolina.

Graham on Friday called for Senate hearings on the decision on Syria.