Kabul in March this year, and a smiling Mahmoud Ahmadinejad mounts the podium beside the Afghan president, Hamid Karzai. His arrival in the Afghan capital immediately after Robert Gates, the US defence secretary, had departed seemed an appropriate metaphor for what was happening in Afghanistan and what had happened in Iraq: exit the Americans, enter the Iranians.
"What are you even doing in this area?" Mr Ahmadinejad spoke to the United States, over the heads of his audience. "Your country is on the other side of the world. What are you doing here?" The Iranian president was making two points: rebuking the US for straying so far from its backyard, and emphasising the important links Iran shares with its eastern neighbour.
This was no diplomatic nicety. Afghanistan is in Tehran's backyard - the countries share a long border; Iran hosted millions of Afghans during the long years of Afghanistan's wars; Dari, one of the two official languages of Afghanistan, is a variant of Farsi, the Iranian language - and Iran expects to have an appropriate amount of influence in the country.
For a period of time early in this decade, Iran was understandably nervous at having US troops on either side of it: boots on the ground in Afghanistan and tanks on the ground in Iraq. But the twin invasions have worked to Iran's advantage, cementing its links in the east and expanding its influence in the west.
With the exception of the US, no other country has had as much influence on Iraq's post-war development as its neighbour. Iranian and Shia influence in Iraq is immense - the United Iraqi Alliance, a Shia-dominated coalition of political parties, is the largest grouping in parliament and tilts strongly towards Iran.
Iran is also deeply embedded in Afghanistan. The New York Times reported that Mr Karzai had extended an invitation to Mr Ahmadinejad immediately after Mr Karzai's invitation to the White House was revoked. The invitation was a warning to the US, which has tens of thousands of troops on the ground in Afghanistan: we have other allies too. It is a message that may well have been on Mr Ahmadinejad's mind during his two-day visit to Lebanon last week.
Mr Ahmandinejad's first state visit to Beirut has focused minds in the region on the growing influence of Iran across the Arab world. But Iran's list of allies is growing far beyond the Middle East. Thanks to its strategic position, energy reserves and frenetic diplomacy, Iran has powerful allies far away from its backyard.
The easiest way to see this is through its nuclear programme. Iran maintains its right under the Nuclear Non-Proliferation Treaty to enrich uranium to supply its energy needs. The European Union, the United States, and many others, in the Middle East and beyond, fear it may be build a nuclear weapon. A new round of sanctions by the European Union and the United States, aimed at curbing what they see as the Islamic republic's nuclear ambitions, took hold this summer.
The Obama administration is reluctant to be drawn into a military confrontation with Iran, especially given its commitments in Iraq and Afghanistan. If Iran decides to "break out" and build a bomb, it is likely it already has the know-how to do so. The wild card remains Israel, which - despite some wild-eyed apocalyptic predictions - recognises that a nuclear-armed Iran would not be an existential threat as much as a strategic one. An Iranian bomb would change the power balance in the region, which worries Saudi Arabia and the Gulf states as well.
Publicly, all the members of the UN Security Council agree that Iran should be clearer about its nuclear ambitions and agree on exerting economic pressure to make it do so. But it is in the gaps between public rhetoric and private action that the limits of Iran's opponents and the extent of its friendships become clear.
Start with Turkey. In the last few years, Turkey has flexed its diplomatic muscle in the region, mediating between Syria and Israel and seeking solutions to sectarian problems in Lebanon and Iraq. Its status as a regional power was confirmed earlier this year when Recep Tayyip Erdogan, Turkey's prime minister, appeared at the Arab League summit as a guest.
Turkey has usually followed the EU line on Iran, but has recently been reluctant to support harsh sanctions. Links between Turkey and Iran are strong. (They conduct around $10bn of trade a year.) Mr Erdogan has called Iran a "friend" and has warm - if not close - relations with Mr Ahmadinejad. He refused to be drawn into the argument concerning last year's disputed Iranian elections, saying it would be an unnecessary interference in the country's domestic affairs.
This summer, Turkey, along with Brazil, pulled off its most audacious diplomatic coup, convincing Iran to agree to a fuel-swap deal that involved Iran shipping its enriched uranium abroad for processing and receiving them back as fuel rods.
The deal broke down, but it highlighted Turkey's willingness to stand up for its own diplomatic links, in conflict with its Western allies. This potentially provides Iran with a powerful ally, because Turkey is intimately connected with international institutions - it has been a member of Nato for decades, is a non-permanent member of the UN Security Council, and may one day be part of the European Union.
It is Turkey, with its strategic relationship with Israel, that is best positioned to make the case that Iran's purported nuclear ambitions can best be resolved by ridding the region of all nuclear weapons. Convincing the Israelis to part with their arsenal may be a step too far for Turkish diplomacy, but in its public pronouncements Ankara reminds the international community that any Iranian nuclear weapon would only add to the region's arsenal.
Russia - a permanent of the UN Security Council - has a more complicated relationship with Iran. The two share extensive economic interests, and Russia has defended Iran on the world stage in the past. But as the US seeks to "reset" relations with Russia, the Kremlin is taking a more guarded line on its relationship with Tehran.
On the one hand, Russia continues to aid Iran's nuclear power efforts, and has shipped uranium fuel to be used in the Bushehr reactor, which is expected to go online before the end of the year.
On the other hand, the Russians bowed to US pressure and refused to go through with the sale of surface-to-air missile systems to Tehran, something it had promised in 2007. The Kremlin last month cancelled the sale and promised to return a $166m advance payment, saying the deal was now illegal under the new round of sanctions.
Thus, the Russians are tilting both ways, treading a fine line between maintaining a strategic alliance with Iran and standing firm with American and European allies.
Yet the relationship between Iran and Russia goes beyond economic links. Because of their shared geography, Russia and Iran harbour concerns about Nato's move eastwards. Iran has attempted to portray such expansion to the eastern states bordering the EU as a threat to Russia and itself. Mr Ahmadinejad has said his country "defends the southern flank" of Asia against Nato influence, and such an argument resonates in the Kremlin. Only this month the head of Nato said that Georgia will become a member of the alliance. If that transpires, Nato would gain influence on Russia's border, in the Black Sea and almost on Iran's doorstep. As much as their economies converge - and could diverge again - the geography of the region will always push Russia and Iran closer.
Iran's biggest defender in the world is China. Iran accounts for around 15 per cent of China's oil imports, and a Middle Kingdom hungry for energy and guaranteed long-term access to energy is unlikely to jeopardise that. If the Chinese could accept a nuclear-armed North Korea on their doorstep as a price for regional stability, they may well be able to accept a nuclear-armed Iran.
The UN Security Council has struggled to hit Iran with punitive sanctions because of Russia and China's support of Tehran. The Chinese in particular want to make sure that any sanctions are tightly focused on Iran's nuclear sector and do not affect the wider economy or their trade links with their neighbour: Iran already builds missiles for the Chinese, and China supplies Iran with weapons and military know-how, a relationship that stretches back to the 1990s. As much as China talks tough on Iran's nuclear ambitions, its priority is bilateral links.
How the West and its allies deal with Iran's nuclear ambitions has become a test case for multilateral diplomacy in the post-Iraq war era. Arab states are understandably nervous about Iran's influence with Syria and in Lebanon. But talk of Iran as a regional power is simply stating the case; its influence in the Arab region is just the beginning. Far beyond its shores, Iran has found allies, sometimes willing, sometimes wary. The question is whether these links will restrain Iran's regional ambitions, or embolden them.
* The National