After the sudden decision to release 15 British naval personnel, the BBC's Iran analyst Sadeq Saba examines how the stand-off played out in Iran, and whether it gained or lost from the crisis.
Why the decision to release the crew?
The Iranian leadership came to the conclusion that holding the 15 sailors and marines would not benefit them any more. It was a triumph for pragmatists in the Iranian leadership. They probably argued that the country was already diplomatically isolated over the nuclear issue and the captives crisis could damage the country even more.
Is it possible to know who took the decision?
The crisis from day one was handled by Iran's Supreme National Security Council, the highest body dealing with foreign policy, defence and security issues. All senior officials, including President Mahmoud Ahmadinejad, take part in its meetings and its decisions are approved by the supreme leader, Ayatollah Ali Khamenei.
Ali Larijani is its secretary and he played a key role in bringing this crisis to an end. President Ahmadinejad was deliberately kept out of this matter in order not to inflame the situation with his hardline rhetoric. But it appears his silence was rewarded by being given the chance to announce the release of the Britons.
What has Iran gained from this episode?
Iran has managed the whole incident cleverly. Iran can argue that it released the naval crew from a position of strength and compassion. Iran wants to be taken seriously as a regional power. Iran can say: "We are not hostage-takers, we are different from Islamic extremists and we are a responsible member of the international community."
The Iranians would see their decision to release the crew as a concession to Britain and the West and they would expect to gain something in return on the issue of their nuclear programme. The most important foreign policy issue for Iran is the nuclear issue.
How will this go down inside Iran?
A lot of Iranians will be relieved that this crisis has come to a peaceful conclusion. The Iranian people are already fearful that the dispute with the West over the nuclear issue could end up in extensive and damaging sanctions and even military action.
How badly has this damaged UK-Iran relations?
The relations between the two countries were already bad over the nuclear issue. In an ironic way this episode may help improve relations between Iran and the UK. Senior officials from the two countries were in direct contact through the crisis.
There could be further talks between London and Tehran to find an arrangement over patrolling the poorly-marked Shatt al-Arab waterway. And Tehran would certainly see its decision to release the sailors and marines as a favour to Britain and would expect some kind of reward.
How has this episode affected Iran's position within the Islamic world?
The episode has enhanced Iran's standing in the Arab and Islamic world. Iran will be seen as a country which foiled British "aggression" against its territory and then, from a position of strength and humanity, decided to release the crew. Iran would say its treatment of the captured Britons was humane - in contrast to the American and British treatment of their prisoners in Iraq (no hoods, no shackles etc).
Might this reflect any change in Iran's foreign policy?
The pragmatism shown in resolving this issue is highly unlikely to repeated over the nuclear issue. That is the key foreign policy challenge for Iran at the moment. In fact, Iran would hope that its decision to release the sailors and marines would reduce pressure on its controversial nuclear programme.