Cash and keeping friendly relations in Afghanistan
Iran benefited in many different ways from the military actions of the US in Afghanistan and Iraq: hostile governments in two neighbouring states were removed, at no cost to Tehran.
Instead, the countries were left weak, and less able to threaten Iran's interests.
Iran's response has been complex and evolving. For a time, the Iranian government was convinced that it was next on the American "hit list".
Often Iran has co-operated with the neighbouring governments and even - to a limited extent - with the US. At times, Iran has been accused of acting behind the scenes to undermine them.
In the case of Afghanistan, some Iranian officials have claimed that they provided US-led forces with intelligence that helped to oust the country's Taliban government in 2001.
Iran also co-operated in setting up the government of President Karzai.
The Iranian and Afghan governments have continued to maintain friendly relations. Hamid Karzai has made a number of trips to Tehran.
At the same time, there have been many reports that Iran is playing both sides in Afghanistan, just as it is alleged to have done in Iraq: on the one hand providing support for the government, on the other hand providing support for insurgents and war-lords, both in order to weaken the Afghan government and to tie down the forces of America and its allies.
A report on the Reuters news agency quotes warnings about the power of Iran from a former governor of Nimroz province, the Afghan province bordering Iran and Afghanistan.
Ghulam Dastgir Azaad said he frequently investigated attacks in which Iran was implicated, either in supplying weapons or training the insurgents.
"We [in this province] share 90km of border with Iran, which Iran easily exploits to send, regularly, explosive devices and weapons into Afghanistan," the former governor told the news agency.
'Bribery and manipulation'
A similar conclusion emerged from an earlier round of leaked documents, published on the Wikileaks website several months ago, in which US military and intelligence officials warned of steadily growing Iranian influence in Afghanistan.
According to the leaked assessments, Iran was involved in programmes to arm and train members of the Taliban, as well as al-Qaeda insurgents and forces loyal to various warlords.
Those making the assessments also expressed concern with Iran's attempt to influence the Afghan political system through bribery and manipulation, though the focus at that stage was on Iran's influence with members of the Afghan opposition.
The Wikileaks reports were, of course, only intelligence assessments, which have been disputed, though they contained a high degree of detail.
Any co-operation between Iran and the Taliban would be a deeply cynical move, as there is no love lost between the Iranians and the Taliban.
But Iran's public attempts to increase influence in Afghanistan are there for all to see: new roads in the west of the country have been built by Iran, and power cables supply Iranian electricity to the city of Herat. There are plans to build an Iranian car plant in the city and to extend Iranian railways into Afghanistan.
Iranian businessmen are highly visible. The Iranian government proudly boasts of its desire to help the Afghan people.
Tehran also has an interest in preventing the smuggling of drugs from Afghanistan, which cause huge social problems in Iran.
Iran swiftly denied the latest claim in the New York Times about handing cash to Mr Karzai.
The Iranian embassy in Kabul said it denied the: "false, ridiculous and insulting claim" from the newspaper, though Mr Karzai has subsequently acknowledged that his office has received bags of cash from the Iranians.
In some ways the revelations do no harm, either to Iran or Afghanistan.
Both Mr Karzai and the Iranian government want Washington to know that US leadership is not going unchallenged in the region.
It is one further headache in what is already a difficult and complicated situation facing the US, Britain and their allies in Afghanistan.