What do two nations with a history of over 200 years of enmity and war do when they seek a change of discourse? Find a common enemy — real or imagined.

For Russia and Iran, traditional foes since the 18th century, that common enemy is the United States, according to political circles in Moscow and Tehran.

Russian President Vladimir Putin dwelt on the idea last month during a speech in Sochi. He said the United States regards “Russia, because of its military might, China because of its rising economic power and Iran because of its nuclear program” as “enemies.”

On that basis, earlier this year, Putin tried to persuade China to transform the so-called Shanghai Group, set up to fight Islamic terrorism, into a fully-fledged military alliance that would also include Iran. When the Chinese wiggled out of the scheme, Putin focused his attention on “closer cooperation” with Tehran.

Russia and Iran share a number of grievances against the United States and its allies in Europe and the Middle East. Both have been subjected to sanctions that have already hit their economies, compounding the effects of global recession. Both claim that the current fall in oil prices represents a conspiracy by Washington and its oil-rich Arab allies to push Russia and Iran, both heavily dependent on export revenues, to the wall.

More important, perhaps, both are persuaded that the United States has long been targeting them for regime change via economic pressure combined with “velvet revolution” dissent.

The worldview of influential circles in Moscow as in Tehran could be described as classically 19th century, with an emphasis on territory and the use of force. Russia is seeking a security perimeter in Eastern Europe, the Baltic States and Trans-Caucasus. Iran locates its own perimeter in Iraq, Syria and Lebanon, with further “territorial depth” in Oman and Yemen. The two powers are also working together to counter US influence in Central Asia with a mixture of bullying and bribery.

Analysts and policymakers in Moscow believe that Russia and Iran could use the remainder of Barack Obama’s presidency to create “irreversible realities” in Eastern Europe, the Middle East and Central Asia.

The phrase “fortochka Obama,” meaning “the Obama window of opportunity,” indicates the belief that America’s next president might not be as pliable as the current one.

Thus, Tehran and Moscow are trying to use the “fortochka Obama” to achieve a number of goals.

First among these is to drag out talks on Tehran’s nuclear program long enough for Iran to reach the so-called “breakthrough” stage, which some experts believe might take another two years.

The next goal is to prop up what’s left of Bashar al-Assad’s regime in Syria to ensure that no alternative government structure can emerge there. Even if Assad controls what is known as “useful Syria,” that is to say 40 percent of territory with half the population, that would be enough.

The next goal is to reduce the effect of sanctions. Russia has already agreed to market $20 billion worth of crude oil on behalf of Iran, circumventing the US-led scheme to freeze a good part of Iranian oil revenues.

More important, Russia has agreed to help speed up Iran’s nuclear program. Last month an agreement to build two more reactors in Bushehr was signed in Moscow as part of an accord to double bilateral trade within the next five years.

Having supplied China with S-400 surface-to-air missiles, Russia is now expected to deliver similar weapons to Iran on the basis of contracts signed almost a decade ago.

Russia and Iran are also working together to exercise influence in both Iraq and Afghanistan before some future US president tries to fill the policy created by Obama’s confused and wayward policies. Using the opportunity created by the so-called Islamic State, Iran is building control on chunks of territory in northeastern Iraq with a view to secure a corridor linking it to both Syria and Lebanon.

Moscow and Tehran are also developing joint plans to modernize facilities in the Syrian port of Tartus used by both Russian and Iranian navies.

By the time the “fortochka Obama” is closed, Moscow and Tehran hope to have consolidated a firewall spanning a vast territory from the Baltics to the Persian Gulf, shielding them against what Putin and Iranian “Supreme Guide” Ali Khamenei designate as “American schemes.”

Obama’s final two years may provide Moscow and Tehran further occasions for making hay while the sun of opportunity shines.

But a Russo-Iranian alliance remains inherently unstable. A history of deep enmity can’t be dissipated overnight, especially when the two putative partners are rivals for domination in the Caspian Basin and Central Asia. More important, a 19th-century-style alliance may prove ineffective in the 21st century.