By Sadeq Saba
BBC World Service Iran analyst
The capture of 15 British Royal Navy personnel by Iranian forces in the Gulf comes at a time when Tehran feels it is under unprecedented international pressure.
The UK and Iran are in a diplomatic stand-off over the incident
The country is diplomatically isolated and feels under a constant and building US military threat.
Earlier this month the UN Security Council passed a resolution against Iran over its nuclear programme.
Iranian diplomats worked very hard to convince some members of the council, such as South Africa, Indonesia and Qatar, to support Tehran's case.
But it failed, and the vote in favour of the resolution was unanimous, further convincing the Iranian leadership that they have few friends left at the UN and that diplomacy is not working in their favour.
Iran is now also militarily encircled by the US forces. American troops are based in almost every country bordering Iran - Afghanistan, Iraq, Turkey, Pakistan and Azerbaijan.
The US Navy has been conducting a series of exercises in the Gulf - the biggest war games in the area since the invasion of Iraq four years ago.
The sense of being under siege is compounded by the US military's detention in January in Iraq of five Iranians.
Hardliners are arguing that any release of the British sailors should be conditional on the release of five Iranians held by the US
Tehran says they are diplomats but the US says the men are members of the Revolutionary Guards with a mission to support Iraqi insurgents.
There has been no consular access to them, no charges brought against them and no information about where they are being kept and under what conditions.
And in December a former Iranian deputy defence minister disappeared in Turkey. Some Western media reported that he had defected to the West.
But the Iranian government and his family say he was abducted by the US or Israel.
All these events and pressures have created a siege mentality in Tehran.
Act of desperation?
It was in this setting that Iranian Supreme Leader Ayatollah Ali Khamenei recently made a significant statement.
He said that so far Iran had acted legally to defend what it saw as its right to pursue a nuclear programme.
The UN Security Council has voted against Iran on the nuclear issue
He went on to say that because the international community had responded with "illegal acts" - by which he meant the Security Council resolutions - Iran itself would from now on feel justified in acting illegally.
Ayatollah Khamenei emphasised that Iran would use any means available to it to defend itself.
It is not clear whether the capture of the British sailors and marines was premeditated or not, but the ayatollah's comments could have given a green light to Revolutionary Guards to seize them.
If it was premeditated, the capture could be interpreted as an act of desperation by a government which feels isolated and threatened.
Iran officially says there is no connection between the detention of the British personnel and its own grievances.
But some hardline elements make a link between their release and other issues.
The Iranian authorities themselves are under mounting pressure domestically to ensure the release of the five Iranians held by the US military in Iraq, and hardliners are arguing that any release of the British sailors should be conditional on the release of the Iranians.
President Mahmoud Ahmadinejad has faced domestic criticism
Noticeable by his absence in all this is Iranian President Mahmoud Ahmadinejad.
From the Iranian side, the crisis has been managed by the country's Supreme National Security Council, the highest body dealing with such important matters.
Its decisions are approved by Ayatollah Khamenei, and all senior officials take part in its meetings.
President Ahmadinejad's silence may suggest that the clerical leadership is deliberately keeping him out of this matter in order to ensure that situation is not inflamed by his usual hardline rhetoric.