Iran today released 10 US sailors it had detained in the Gulf, moving within hours to head off a potential crisis as it prepares for the lifting of sanctions.
A dramatic series of events started with the sailors - nine men and a woman - being taken into custody after their two patrol boats drifted into Iranian territory late yesterday.
US and Iranian officials scrambled to defuse the situation, which unfolded as Iran prepares to finally implement a nuclear deal with world powers aimed at ending the Islamic republic's long international isolation.
After informal talks between Washington and Tehran, a statement from Iran's Revolutionary Guards, describing the sailors as Marines, was read out on state television confirming they were free.
"It was determined that the detained American Marines did not enter Iranian waters intentionally. Following their apology, they have been released to international waters in the Gulf," it said.
Still images used in the report showed the sailors sitting calmly on Persian rugs. Iran had earlier said they were being well treated.
Pictures of the US boats, which had green-and-black camouflage patterns, were also shown.
A Pentagon statement confirmed the sailors were free.
"There are no indications that the sailors were harmed during their brief detention," it said, adding: "The Navy will investigate the circumstances that led to the sailors' presence in Iran."
Admiral Ali Fadavi, the naval commander of the Guards, said an investigation established that "this trespassing was not hostile or for spying purposes" and the sailors had entered Iranian territory "due to a broken navigation system".
US officials had said one or both of the boats had suffered mechanical problems and been taken to Farsi Island, which lies roughly midway between Iran and Saudi Arabia in the Gulf and houses a base of the Guards, which has its own naval units.
Radio contact was lost with the two vessels - which US officials said were riverine patrol boats under 20 metres in length - while they were en route from Kuwait to Bahrain.
American officials said they had received assurances from Iran that the crews would be allowed to sail onwards come first light.
Washington and Tehran have no diplomatic relations but US Secretary of State John Kerry called Iranian counterpart Foreign Minister Mohammad Javad Zarif to discuss the incident.