ABC News December 31, 2019

ANALYSIS: Why the US embassy in Baghdad was assaulted on New Year's Eve

WATCH: Pentagon to deploy troops after Iraqi protesters storm US embassy

For many Americans, New Year's Eve brought a startling sight -- an American embassy under siege, assaulted by protesters and seemingly in danger of falling into enemy hands.

But it's 2019, not 1979. And it's Baghdad, not Benghazi or Saigon.

Orchestrated by pro-Iranian militias, these protests are about domestic politics in Iraq and a country torn between two allies competing for influence -- Iran, Iraq's powerful western neighbor and fellow Shiite-majority nation, and the United States, bonded by the fight against the Islamic State and U.S. funds that helped stand up the government and keep it standing.

(MORE: Pentagon expects to deploy troops to Mideast after Iraqi protesters assault US embassy, torch guardhouse to protest airstrikes)
Ahmed Jalil/EPA via Shutterstock
Members of Iraqi Shiite 'Popular Mobilization Forces' armed group and their supporters attack the entrance of the US Embassy in Baghdad, Iraq, Dec. 31, 2019.

Since October, mass anti-government demonstrations have flared up across the country, protesting corruption and Iranian influence, both of which mire Iraqi politics. But Tuesday's crowds were entirely different -- pro-Iran, pro-Shiite militias backed by Iran and angry at recent U.S. airstrikes.

Last Friday, an American civilian contractor was killed by rocket fire at K1, an Iraqi base that houses U.S. troops outside Kirkuk, in Iraq's north. The attack, which injured several Iraqi and other U.S. troops, was blamed on a pro-Iranian militia called Kata'ib Hezbollah, or KH. Two days later, the U.S. military struck back, killing at least 25 members at five sites in Iraq and Syria.

Designated by the State Department in 2009 as a foreign terrorist organization, KH has close ties to Iran's Quds Force, an elite unit of its Islamic Revolutionary Guard Corps that works outside of Iran carrying out unconventional attacks and intelligence operations.

But while the U.S. considers KH a terror group, they are also a political force in Iraq that politicians need to placate and work with. The Iraqi Prime Minister's office Tuesday "condemn(ed)" the strikes on KH as an attack "on Iraqi military units" -- a sign of how intertwined they are with the government.

The Trump administration said it was a defensive response and a strong signal to Iran to leave U.S. personnel alone, even through proxy forces. But those U.S. strikes infuriated many Iraqi officials, those aligned with Iran and Shiite militias. U.S. forces are in the country to train Iraqi troops and fight ISIS together, and they saw U.S. strikes on KH on Iraqi territory as a violation of Iraqi sovereignty.

"After the U.S. retaliation, the Iraqi government had to let anger by local members of KH play out publicly, appeasing both a key element of their political base and Tehran," said retired Col. Steve Ganyard, a former Deputy Assistant Secretary of State and now an ABC News contributor.

(MORE: Video shows aftermath of US strike on Iran-backed group in Iraq amid concerns violence could escalate)

Delivering a message to Washington, several Iranian-backed political groups and militias, also known as Popular Mobilization Units, showed up for protests on Tuesday at the U.S. embassy. Eyewitnesses said Iraqi security forces let them enter the otherwise heavily fortified Green Zone, where the central government and many foreign embassies are housed.

That contrasts with the violence that those same security forces used to keep the anti-government protesters out in October and November, deploying live ammunition and, at times, killing protesters.

Khalil Jenkins/AP
In this photo provided by U.S. Department of Defense, the Army's AH-64 Apache helicopter from 1st Battalion, 227th Aviation Regiment, 34th Combat Aviation Brigade, conducts overflights of the U.S. Embassy in Baghdad, Iraq, Dec. 31, 2019.

Tuesday's crowds, which included militia leaders and Shiite politicians, did not breach the embassy compound itself, but they did make it past an outer wall, charging up to the embassy security gates, staring U.S. security personnel in the face and smashing and torching property outside.

How was that possible?

"Because it was planned," said Ganyard. "Look at the overhead views of the protest. Carefully abiding by set limits. ... It was staged and had the approval of the Iraqi government."

(MORE: US civilian contractor killed, several troops injured in rocket attack on Iraqi military base)

"The Iraqi government was never going to let Iranian proxies take over the U.S. embassy," he added. But they had to let them get far enough to let off steam and to dissipate some of the anger in those ranks.

Iran, however, doesn't want things to go so far that the U.S. has a reason to strike its personnel.

Instead, as it has done for months now -- since Trump withdrew from the nuclear deal and implemented a sanctions regime far more biting than any before -- it pokes at the U.S.

First, there were attacks on oil tankers, then the downing of a U.S. drone, and the slow steps away from its commitments under the nuclear accord. Iran escalated in September, with a massive attack on a Saudi oil facility and scattered rocket attacks on targets in Iraq where U.S. troops are stationed.

Iranian leaders will keep poking at the U.S. to take the heat off them, as the country's economy crumbles under intense U.S. sanctions and its own citizens demonstrate in cities across the country -- demanding economic opportunity, an end to corruption and an end to foreign excursions.

Turmoil in Iraq and scenes of smoke and fire outside the U.S. embassy -- the U.S. seal itself stolen from the embassy gates -- are all a welcome distraction for Tehran from Iraqis' deep anger over its tentacles in their country.

But it won't last forever. The risk is when it runs out, will Iran push too far with its next jab or will the U.S. response prompt a spiral out of control?

Defense Secretary Mark Esper authorized an infantry battalion of about 750 soldiers to deploy to the Middle East "immediately" and Secretary of State Mike Pompeo said Tuesday that U.S. personnel are there to stay at the embassy, while Kata'ib Hezbollah members and supporters began setting up tents out front and vowed to send a new message -- pushing for legislation to expel U.S. forces.

The next chapter isn't written yet, but one thing seems certain: Iraq will be left to bear the bloody brunt of it.