Mohamad Bazzi is a journalism professor at New York University and former Middle East bureau chief at Newsday, where he was the lead writer on the 2003 Iraq war and its aftermath. A former fellow at the Council on Foreign Relations, he is writing a book on the proxy wars between Saudi Arabia and Iran. (Twitter: @BazziNYU ) The opinions expressed in this commentary are his.

(CNN) If there is one regional player that gained the most from America's gamble in Iraq, it is Iran. With its invasion in 2003, the United States ousted Tehran's sworn enemy, Saddam Hussein, from power. Then Washington helped install a Shiite government for the first time in Iraq's modern history. As U.S. troops became mired in fighting an insurgency and containing a civil war, Iran extended its influence over all of Iraq's major Shiite factions.

Today, the Iranian regime is moving to exert influence beyond its Iraqi proxies, and is comfortable taking overt military action. There is no one to restrain Tehran, and the rise of ISIS, which views Shiites as apostates, threatens the interests of all Iraqi Shiite factions and of the Iranian regime.

In late November, Iranian warplanes launched several airstrikes against targets in eastern Iraq, pushing back ISIS militants who had neared a self-declared "buffer zone" that Iran established along the border.

It was the latest example of how Iran is expanding its military and political influence in Iraq, a country wracked by a complex civil war that leaves it open to outside manipulation.

Iraq is at the center of several regional proxy battles: Iran is heavily involved in shaping Iraqi policy, while ISIS represents spillover from the Syrian civil war next door. The militant group is also a byproduct of the Gulf Arab states that support Sunni jihadists in both Syria and Iraq. And the United States is bombing ISIS and other jihadist groups in Iraq and Syria.

The Iranian regime has several concerns: Iraq provides strategic depth and a buffer against Saudi Arabia and other Sunni Arab states that are competing with Iran for dominance over the Persian Gulf. More broadly, Tehran wants to ensure that Iraq never again poses an existential threat to Iranian interests, as Saddam did when he invaded Iran in 1980, instigating the eight-year Iran-Iraq war that devastated both countries.

Saddam was supported by the Sunni Arab states and most Western powers. (The Shiites are the majority in Iraq, but since its independence in 1932, the country had been ruled by the Sunni minority until the U.S. invasion in 2003.) Iran will do whatever is necessary to keep a friendly, Shiite-led government in power in Baghdad.

The long game

Iran has excelled at playing the long game, especially in Iraq.

Iran's willingness to spread money around to various proxies and factions gave it great agility in maneuvering through Iraqi politics. Soon after the U.S. invasion, Tehran reached out to the Shiite cleric Muqtada al-Sadr -- who was an early critic of Iranian meddling in Iraq -- and financed his growing militia and social service networks.

One diplomatic cable sent by U.S. Ambassador to Iraq Christopher Hill to officials at the State Department in November 2009 estimated that Tehran's financial assistance to its Iraqi surrogates ranged from $100 million to $200 million a year.

Iran also was willing to invest across sectarian lines: "The IRIG (Islamic Republic of Iran Government) recognizes that influence in Iraq requires operational (and at times ideological) flexibility," Ambassador Hill pointed out in his cable. "As a result, it is not uncommon for the IRIG to finance and support competing Shia, Kurdish, and to some extent, Sunni entities, with the aim of developing the Iraqi body politic's dependency on Tehran's largesse."

Like Iraq's other neighbors, Iran helped fuel and prolong the Iraqi insurgency and civil war. The Iranian Revolutionary Guard Corps financed, armed and trained numerous Shiite militias that targeted U.S. troops and Iraq's Sunni community. The Iranians provided rockets, explosives, machine guns, sniper rifles, rocket-propelled grenades and other small arms. They also brought Iraqi militiamen to Iran to be trained in the use of explosives and as snipers.

The United States helped Iraq's Shiite factions compromise on Nuri al-Maliki as prime minister in 2006. As he struggled to remain in power, he became more dependent on Iran. He grew more repressive and authoritarian, using the Iraqi security forces to intimidate political rivals and exclude Sunnis from power.

For Iran, Maliki was a reliable ally, who allowed Iranian flights over Iraqi territory to transport weapons and manpower to shore up Bashar al-Assad's regime in Syria after a popular uprising in 2011. Maliki also allowed thousands of Iraqi Shiites to cross the border and fight alongside the Syrian regime.

Since ISIS swept through northern Iraq in June, Tehran has mobilized to protect the Shiite-led government from the Sunni militant threat. General Qassim Suleimani, commander of the Quds Force of the Iranian Revolutionary Guard Corps, traveled to Baghdad at the start of the crisis to coordinate the defense of the capital with Iraqi politicians and military officials.

He also directed Iranian-trained Shiite militias—including the Badr Brigade and the League of the Righteous, two notorious militias responsible for widespread atrocities against Sunnis—in the fight against ISIS. With a weakened and corrupt Iraqi military, the militias have proven crucial in stopping ISIS' advance.

JUST WATCHED Iran responsible for gains against ISIS? Replay More Videos ... MUST WATCH Iran responsible for gains against ISIS? 02:59

When Iraq's political elite finally agreed in August to replace the divisive and sectarian Maliki as Prime Minister, the Iranian leadership—along with the United States and most Western powers—threw their weight behind his successor, Haider al-Abadi. Like Maliki, he is a leader of the Dawa Party, a Shiite Islamist group supported by Iran.

In recent months, U.S. officials say, Tehran has provided tons of military equipment to the Iraqi security forces and has been secretly directing surveillance drones from an air base in Baghdad. Iran has also sent hundreds of its Quds Force fighters to train Iraqi forces and coordinate their actions.

But last month was the first time that Iran used its fighter jets to directly bomb ISIS targets inside Iraq, striking in eastern Diyala province where the fighting neared the Iranian border.

Iranian officials have slowly acknowledged their covert operations inside Iraq. "Iran has helped Iraq in an advisory role and has quickly organized Iraqi militias," Gen. Amir Ali Hajizadeh, commander of the Revolutionary Guards' Aerospace Forces, told the Fars News Agency in September. "Were it not for Iran, the Islamic State would have taken over Iraqi Kurdistan."

In late December, a Revolutionary Guards commander, Brigadier General Hamid Taqavi, was killed by a sniper in the Iraqi city of Samarra while he was training Iraqi troops and Shiite militia fighters. Taqavi was the highest-ranking Iranian official to be killed in Iraq since the Iran-Iraq war. Thousands of Revolutionary Guards gathered for his funeral in Tehran on Dec. 28, where Ali Shamkhani, head of Iran's Supreme National Security Council, told mourners: If "people like Taqavi do not shed their blood in Samarra, then we would shed our blood" within Iran.

Iraqi leaders warned that as long as the United States did not provide military assistance, they had no choice but to ask Iran for more help. "When Baghdad was threatened, the Iranians did not hesitate to help us," Abadi, the Iraqi prime minister, said in a recent television interview in Baghdad. He noted that unlike Iran, the United States "hesitated to help us when Baghdad was in danger, and hesitated to help our security forces. And the reason Iran did not hesitate to help us was because they consider ISIS as a threat to them, not only to us."

The proxy wars

Today's Middle East was shaped by several proxy wars that unfolded over the past decade. In Iraq, neighboring Sunni regimes backed Sunni militants, while Iran supported Maliki's Shiite-led government and Shiite militias. In Lebanon, an alliance between Washington and authoritarian Sunni Arab regimes—Egypt, Saudi Arabia and other Gulf countries— backed a Sunni-led government against Hezbollah, a Shiite militia funded by Iran.

And in the Palestinian territories, Iran supported the militant Hamas, while the United States and its Arab allies backed Palestinian President Mahmoud Abbas and his Fatah movement.

When various Middle Eastern regimes realized that America would lose its war in Iraq, they began maneuvering to protect their interests and to gain something out of the American defeat.

Saudi Arabia, which viewed Iraq as a bulwark against Iranian influence, tried to undermine the Shiite-led government in Baghdad. The ruling Al-Saud dynasty views itself as the rightful leader of the Muslim world, but Iran has challenged that leadership for several decades.

Although Saudi Arabia has a Sunni majority, its rulers fear Iran's potential influence over a sizable and sometimes-restive Shiite population concentrated in the kingdom's oil-rich Eastern Province. In Bahrain (another American ally in the Gulf), the Shiite majority is chafing under Sunni rulers who also fear Iran's reach.

Through a combination of funding, training for militias and political support, Iran will continue to extend its influence over the major Shiite groups in Iraq. Maliki did not start out as beholden to Iran, but as he struggled to remain in power, he became more dependent on Tehran.

Even if Abadi, the new Prime Minister, has shown signs that he wants to be closer to the West, he needs Iranian support to keep his government in power.

More broadly, the United States and Iran now share common interests in defeating ISIS and maintaining a stable regime in Baghdad that can transcend sectarian conflicts. The Obama administration and Tehran insist that they are not coordinating directly in Iraq, but they essentially have an undeclared alliance.

Washington has been looking the other way as Iran increased its military involvement over the past six months. Without committing far more U.S. troops and resources, there is little that the Obama administration can do to contain Iranian power in Iraq.

Iran has many levers to maintain its influence over Iraq. It will not hesitate to use them, even if that means taking on a deeper military role in a civil war that has no end in sight.