by Robert Beckhusen. Robert Beckhusen is a freelance writer who contributes regularly at War is Boring. He’s also written for publications including C4ISR Journal, Wired, The Daily Beast and World Politics Review. You can follow him on Twitter.

Fighters from the hard-line Islamic State of Iraq and the Levant (ISIS) are bearing ever closer to Baghdad after a rapid assault which seized Mosul — Iraq’s second-largest city — on Tuesday. Iran, for its part, is rushing troops and aid to the Iraqi government to prevent the Sunni extremist group from taking more territory.

To be specific, Iran has sent two Quds Force battalions (the elite expeditionary force of the Islamic Revolutionary Guards Corps) to defend the Shia holy cities of Najaf and Karbala — in addition to Baghdad. Qassem Suleimani, the Quds Force’s most senior commander, is also reportedly in Baghdad to advise the mission.

These reinforcements have a chance of blocking ISIS — who number as few as 800 fighters — from advancing much further. But the situation is unfolding so rapidly and chaotically, it’s almost impossible to tell what will happen next. ISIS’s victories could be temporary if more solid forces are arrayed against it. To this date, the group’s success has as much to do with the nonexistent morale and disintegrating leadership of the Iraqi army, as it does with ISIS’s own fanaticism and hard-wired combat experience earned in Syria.

But even if ISIS is stopped in its tracks, Iraqi forces with Iranian help will have serious problems pushing ISIS out of the country completely. For one, Iran is going broke, and it’s already tightening funds for its favorite proxy army Hezbollah. Tehran bankrolls Hezbollah — which serves to expand Iran’s influence in the Lebanon and Syria — and supplies both weapons and training.

Lebanon’s Daily Star detailed the economic strain extending from Iran to Hezbollah, which has been forced to cut back employees in “social, health, media and service institutions,” according to the newspaper. Iran suffers from rampant unemployment and inflation, and it has spent heavily — to the order of $600 million per month — to keep the war in Syria going in favor of Bashar al-Assad. Now Iran might have to fund another war — this one right across its border.

“Rogue behavior carries costs,” wrote Oren Kessler and Rupert Sutton of World Affairs. “The Islamic Republic’s nuclear program has devastated its economy, raising fuel, food, and energy prices for ordinary Iranians. Its three-year campaign to save the Syrian regime is bleeding its bank accounts, and damaging its ability to fund terror beyond its borders.”

Hezbollah’s leadership has also asked foreign cells to come up with new funding. Hezbollah’s military council has discussed pulling out of Syria — although this wouldn’t happen without Tehran’s approval. Hezbollah provides funding for a litany of civic and religious organizations, and has been forced to reduce funding in these areas as well, according to the Daily Star.

In addition to thousands of Hezbollah fighters, Iran also supports several other Shiite volunteer militias in Syria and up to 5,000 Iraqi Shia foreign fighters. The Iranian Revolutionary Guards has an estimated 1,500 troops in Syria.

According to the Wall Street Journal, Iran is considering deploying some of these volunteers to Iraq if “initial deployments fail to turn the tide of battle in favor of Mr. Maliki’s government.” But there’s no evidence Iran’s economic woes have hit these militias as they have Hezbollah.

In any case, the strain on Iran’s finances will only worsen if it’s embroiled in a wider regional war. Ironically, one source of relief could be the United States, which is currently negotiating a nuclear deal with Iran in exchange for lifting sanctions. A deal could be months away, if ever. But with the U.S. mulling armed assistance to Iraqi forces, and with Iranian forces already operating in Iraq, there’s a perplexing scenario of an emerging — and de facto — U.S. and Iranian alliance.