While many in the United States discussed the ramifications of Iran losing Syria, Tehran was busy taking it. The Islamic Republic’s aid to the Syrian regime is not about cutting its losses, but about achieving economic, political and strategic goals that had previously been out of reach. There is nothing ideological about this alliance — it is and always has been pure and unabashed self-interest. The gruesome images coming out of Syria make it hard to imagine it in such terms, but Iran sees Damascus as an investment.

The Iranians have capitalized on the Syrian civil war to solidify their political control over the Syrian regime, changing a shaky ally into a dependable proxy. The origin of the Syrian-Iranian alliance is the Iran-Iraq war, as Syria was one of just two Arab countries to support the Iranians in their fight against Saddam Hussein. Syria’s support for Iran throughout this conflict was not about the ideological affinity of the two regimes but rather a shared interest in weakening Iraq. In fact, Syria and Iraq were much more culturally and ideologically aligned than Syria and Iran; Syria and Iraq were controlled by secular Arab Ba'athist regimes, while the government of Iran was a theocracy.

In the wake of the collapse of its longtime Soviet patron, there were several indications that Syria would try to follow in the footsteps of Egyptian leader Anwar Sadat by making peace with Israel and reorienting itself towards the U.S. and away from Iran. Serious peace talks were held between Syrian President Hafez al-Assad and the Israeli leadership in 1993 under Yitzhak Rabin, in 1995 under Shimon Peres, and in 2000 under Ehud Barak. The negotiations were unsuccessful largely due to the inflexibility of both countries regarding Syria's demand that Israel fully withdraw to the pre-1967 boundaries, based on the precedent set by the Israeli peace accords with Egypt.

Though U.S.-Syrian relations did improve in the 1990s and later included some cooperation against al-Qaeda after 9/11, the 2003 Iraq war and Syrian assistance to those resisting the U.S. occupation of Iraq caused the thawing relations to freeze over. Hopes for an Israeli-Syrian peace were revived one last time when negotiations resumed in 2007 with the help of Turkey. The following year, the U.S. State Department reviewed its Syria policy, “leading to an effort to engage with Syria to find areas of mutual interest, reduce regional tensions, and promote Middle East peace.” Tehran was obviously concerned enough about the prospect of Syria “flipping” that Hussein Shariatmadari, an advisor to Iran's supreme leader, publicly warned against it. However, U.S.-Syrian relations would soon sour as a result of Assad’s crackdown on Arab Spring protests, and since then the U.S. has withheld diplomatic efforts to put a crack in the “axis of resistance.”

By 2012, Iranian concerns regarding the blossoming of U.S.-Syrian relations or the signing of Israeli-Syrian peace accords were little more than a memory. As the conflict in Syria took on more sectarian and violent dimensions, the Iranian Revolutionary Guard Corps (IRGC) supported an increasingly dependent and brutal Assad in his suppression of dissent. By January 2013, the Iranians had so much influence over the Syrian agenda that in a prisoner swap between the regime and the rebels, Assad did not demand the release of local loyalists but of 48 IRGC commanders in exchange for more than 2,000 rebels and anti-regime activists.

Also, the economic gains that Iran stands to make from this conflict have often been overlooked, as most assume that Tehran is just willing to stomach billions of dollars in financial losses in exchange for strategic benefit. Though Iran was often pushing to exert greater influence over Syria in their marriage of convenience, the Assads made sure to minimize their economic dependence on Iran, a fact evident in the extremely small volume of trade between the two countries in the years leading up to the Arab Spring.

While trade between the U.S. and Syria reached $940 million in 2010, the volume of trade between the supposed “Tehran-Damascus axis” was less than one-half that. One could argue that this was merely incidental or that economic cooperation between the countries simply wasn’t necessary, but counterbalancing Iranian influence by strengthening economic ties to other countries was Damascus' unofficial state policy rather than coincidence. For example, out of six cellular companies vying for the rights to operate a third mobile network in Syria in 2010 (including companies from Qatar, the UAE, Turkey and Saudi Arabia — ostensibly more hostile to the “axis of resistance”), the only bid rejected was from an Iranian company rumored to be connected to the IRGC.

However, after the uprising against Assad began and Syria’s trading partners abided by the sanctions against it, Iran was not placed “in a foreign-policy predicament” but rather was positioned to exploit the fact that Assad no longer had the luxury to keep it at arm’s length. Despite Syria’s declining economic state, Syrian-Iranian trade has tripled since 2010, reaching $1 billion in 2014, and is expected to continue growing. Also, Iran’s close ties to the regime and its status as the Middle East’s largest producer of cement and iron mean that it is well-positioned to benefit from Syria’s ongoing destruction and reconstruction.

Though Iran has largely planned its strategy under the assumption that the Assad regime would survive, it has also trained and armed Syrian militias to serve Iranian interests long after state institutions have collapsed. Iran has invested a great deal in keeping Assad afloat while preparing for his fall, and as part of a “plan B” to maintain influence in case the Assad regime collapses, Iran and Hezbollah are cultivating relationships with minority-based militias fighting on Assad’s side. These militias include the shadowy criminal network with close ties to the Assad family known as the shabiha as well as the jaysh al-sha’bi which have been trained, and supplied by Iran and Hezbollah based on the model of the Iranian Basij militia. The more loosely affiliated militias will likely prove durable allies should Iran decide to cut costs by supporting a Shi'ite insurgency in a post-Assad Sunni-controlled Syria, rather than continuing to prop up the Syrian government. In essence, Iran has used the Syrian civil war as an opportunity to both nurture Assad’s political, economic, and military dependence and simultaneously support and train militias that can serve the interests of the Islamic Republic should Assad’s government prove unsustainable.

Granted, the fragmentation of Syria translates into only partial Iranian control of the country. Yet, in spite of the fact that it holds only about 50 percent of the territory, the Assad regime controls between 55 and 72 percent of the remaining population. ISIS may hold a great deal of territory in Syria, but it is clear from the sparsely dotted cities in the maps of its territory that it controls mostly Syrian desert and rural areas rather than urban centers. Provided the joint Syria-Iran-Hezbollah efforts can hold a few key areas like the road between Damascus and Beirut, the Assad regime’s ability to serve as a conduit for weapons flowing from Iran to Hezbollah will remain intact.

The Syrian civil war is approaching its fifth year and the P5+1 is hammering out a nuclear deal with Iran that could potentially unfreeze hundreds of billions of dollars in assets. Due to Tehran’s backing thus far, the numerous predictions that Assad could fall any minute remain unfulfilled. Though there is a great deal of uncertainty regarding the final outcome of the Syrian civil war, one thing is clear: Iran will be ready.

Ari Heistein is a research associate in the Middle East Program at the Council on Foreign Relations.