Aaron David Miller is a senior fellow at the Carnegie Endowment for International Peace and author of " The End of Greatness: Why America Can't Have (and Doesn't Want) Another Great President ." Miller was a State Department Middle East analyst negotiator in Democratic and Republican administrations. The opinions expressed in this commentary are those of the author; view more opinion articles on CNN.

(CNN) Early Tuesday, pro-Iranian Iraqi militia members and demonstrators stormed the US Embassy compound in Baghdad after the Trump administration's airstrikes on a Iranian-backed militia on Sunday. The embassy attack, perhaps the worst crisis between Iraq and the US since 2003, reveals the inconsistency and vulnerability of the Trump administration's policies toward both Iran and Iraq.

Like a modern-day Gulliver, President Trump is metaphorically wandering around a Middle East where he'd rather not be, tied up both by smaller powers whose interests are not his own -- and by America's illusions about the region, perpetuated by Trump who somehow believes he can force Iran to bend to his will. The odds are that the situation for the US in Iraq and Iran is likely to get worse before it gets still worse.

US in a bind

The US had little choice but to respond on Sunday to recent pro-Iranian Iraqi militia attacks against US forces in Kirkuk, which claimed the life of an American contractor and wounded US forces. The Trump administration needed both to deter and signal to Tehran that such attacks were unacceptable. Failure to do so would have left the administration in violation of one of its own red lines -- that the US would not tolerate attacks against Americans.

But the US attacks in response seemed intentionally disproportionate, killing at least 25 militia and injuring scores of others . And it seems the US did not take into consideration that the airstrikes would seriously embarrass the government of Iraq or could lead to reactions like a storming of the American Embassy.

The storming of the embassy raises questions as to why the administration didn't think through how Tehran might respond to Sunday's airstrikes on five pro-Iranian militia bases in Iraq and Syria, and why security at the embassy wasn't beefed up in advance.

The US doesn't have home court advantage

Iran has effectively coordinated attacks against US forces before, especially during the early phases of the Iraq war. But following this most recent attack, it should be clear that Washington isn't on a level playing field in Iraq and that Iran enjoys a tremendous advantage, for a number of reasons.

JUST WATCHED Trump tweets 'threat' to Iran over embassy attack Replay More Videos ... MUST WATCH Trump tweets 'threat' to Iran over embassy attack 02:06

First, the Iraqi government is much more financially and economically dependent on its Iranian neighbor than it is obligated to the US. Iraq is the second-largest importer of Iranian non-oil commodities, and Iran is a key supplier of electricity to the country's southern region.

Second, while we have spent billions in training, equipping and assisting Iraqi security forces with arguably a fair amount of success, the integration of several of the most pro-Iranian militias into those security forces is increasingly problematic. These forces have played a role in brutally helping the Iraqi government repress recent Shia demonstrators, and the initial storming of the embassy compound could not have been accomplished without government security forces' acquiescence to the militias.

Third, the US handed Iran a tremendous propaganda advantage. It has turned anti-Iranian sentiment among Iraqis against the US and sparked protesters at the US Embassy to throw rocks and chant " Death to America ."

What's Trump's end game with Iran?

Things appear calmer around the embassy Wednesday morning. But it's too early to determine whether recent events will lead to a broader US confrontation with Iranian proxies or Iran itself. One thing is clear: President Trump's approach to Iran is muddled by a number of cross-cutting factors which make any policy move on Iran unpredictable.

On one hand, in the wake of his withdrawal from the Iran nuclear accord, Trump launched a tough-minded campaign of maximum pressure on sanctions that's devastated Iran's economy. But such sanctions have neither halted Iran's regional activities in Lebanon, Yemen or Iraq, nor made it any more flexible on nuclear issues.

On the other hand, his tough rhetoric withstanding, Trump has made clear many times that he'd like to sit with Iranian President Rouhani, presumably to negotiate a new and better nuclear deal. And risk averse when it comes to confronting Iran directly, he chose not to respond by striking Iran in retaliation for its attacks on Saudi oil facilities last September.

As we enter 2020 and an election year, it's unlikely that this confusion will end anytime soon, raising serious questions about what Trump really wants -- to weaken Iran, change the regime or cut a new nuclear deal.

Get our free weekly newsletter Sign up for CNN Opinion's new newsletter. Join us on Twitter and Facebook

Trump, who ran on a platform of withdrawing from the Middle East and would just as soon get out of these unwinnable wars, faces a genuine conundrum: how to avoid looking weak but avoid triggering a messy conflict with Iran and deeper involvement in Iraq that would be certain to alienate his base and energize his opponents.