Who'd have thought President Trump would be so eager to imitate one of President Barack Obama's worst mistakes in the Middle East?

In 2011, Obama nearly snatched defeat out of the jaws of U.S. military victory over al-Qaeda in Iraq (AQI) – by pulling the last 10,000 U.S. troops out too soon. AQI resurfaced as ISIS, seizing massive chunks of Iraq and Syria, and threatening the West.

Now, Trump wants to pull an Obama in Syria.

"I want to get out. It's time," the president said on Tuesday, speaking of withdrawing the 2,000 U.S. troops in Syria that are helping our Kurdish allies eliminate the last pockets of ISIS.  Even as he spoke, Gen. Joseph Votel, head of U.S. military operations in the Mideast, was telling a conference in Washington that the U.S. presence in Syria was still needed to consolidate gains.

A slight White House walk back of Trump's remarks on Wednesday barely hid his eagerness to exit Syria prematurely. Does he not realize the beneficiaries would be Iran and  Russia – and ISIS, which is trying to regroup and could still threaten the West?

What was so astonishing about the president's Syria blurt was that it ignored all the advice from his military, security advisers, and Middle East allies. Apparently, none were alerted before he started signaling at a political rally last week that he would be "making a [Syria] decision very quickly."

Even as Trump dropped his Syria bombshell on Tuesday, Votel was detailing why a continued U.S. presence is essential to cement the defeat of the jihadis. "The hard part is in front of us," he said at a U.S. Institute for Peace conference. "That is stabilizing these areas, consolidating our gains, getting people back into their homes.

"There is a military role in this, especially in the stabilization phase."

Again, we are talking 2,000 troops, not a massive presence, mainly special forces, mostly based in the expanse of northeast Syria that is home to the Syrian Kurds. Some U.S. forces are also based in areas home to Sunni Arabs who fought alongside the Kurds to retake the ISIS caliphate capital of Raqqa.

The U.S. presence is vital for stabilizing those areas sufficiently so that refugees can go home to towns destroyed by ISIS.  This does not mean nation-building – the president's bete noire – but it does mean clearing mines and restoring electricity and water.

In Syria, this work is being done on a (relative) shoestring, with $100 million being spent so far. (Trump just froze a proposed $200 million more.) The money is an investment in restoring normal life so that Sunni jihadis can't rebuild roots among unhappy Sunnis. U.S. forces are also training local security forces to keep close watch in places such as Raqqa. Coalition allies are pitching in with manpower and cash.

A Syrian Kurdish representative in Europe told me by phone: "What we hear from the Americans on the ground is that they will be there for another two years to finish the job." Of course, that is contrary to what the president said.

The continued U.S. presence in Syria is key for reasons that go beyond stabilization. Syria has become a geopolitical battleground where U.S., Russian, Iranian, Saudi, Turkish, and Israeli interests are competing.

This rivalry can only be resolved through diplomacy. If the United States pulls out, it will lose all leverage at the bargaining table. That would leave the Russians and Iranians with all of the key cards.

The biggest beneficiary of a U.S. pullout – besides Islamist jihadis — would be Tehran, whose hold over Syria is deepening.  A U.S. exit would make it easier for Iran to solidify a land bridge through Syria to Lebanon to send men and weapons to Hezbollah fighters. This would increase the growing likelihood of a war between Iran and Israel over Iran's role in Syria.

One must ask: Why on earth is Trump so eager for a move that would benefit Tehran?

That question is key, given that every senior Trump security adviser has opposed a hasty Syria exit. That includes Defense Secretary James Mattis, former Secretary of State Rex Tillerson, and outgoing national security adviser H.R. McMaster. The latter duo's  replacements, Mike Pompeo and John Bolton, are hawks on Russia and Iran, and aren't likely to approve of handing Moscow and Tehran – not to mention ISIS —  a free gift.

Yet, Trump has done just what he criticized Obama harshly for: signaled his Syria strategy in advance and conveyed his eagerness to quit before the job is done. He has alerted Iran and Russia  — and ISIS — that they don't need to worry. He seems more attuned to his political base — he promised a Mideast pullout during the 2016 campaign — than to U.S. security concerns.

"The reason not to pull out [of Syria] is to avoid another Iraq 2011," said USIP's senior Syria adviser Mona Yacoubian at the conference. "That pullout set the stage for ISIS."

Trump damned Obama for that mistake in Iraq.  But in Syria, he appears bent on doing the same thing.