By Bozorgmehr Sharafedin and Phil Stewart
DUBAI/WASHINGTON (Reuters) - Iran freed ten U.S. sailors on Wednesday a day after detaining them aboard two U.S. Navy patrol boats in the Gulf, bringing a swift end to an incident that had rattled nerves shortly before the expected implementation of a landmark nuclear accord.
Iran's Islamic Revolutionary Guard Corps (IRGC) said it had released the sailors after determining they had entered Iranian territorial WATERS (WAT.NY)by mistake. IRGC Rear Admiral Ali Fadavi said earlier the boats had strayed due to a broken navigation system.
The quick resolution contrasted with previous cases in which British servicemen were held by Iran for considerably longer, in once case almost two weeks.
Iran expects the U.N. nuclear watchdog to confirm on Friday it has curtailed its nuclear programme, paving the way for the unfreezing of billions of dollars of Iranian assets and an end to bans that have crippled oil exports.
"Our technical investigations showed the two U.S. Navy boats entered Iranian territorial waters inadvertently," the IRGC said in a statement carried by state television. "They were released in international waters after they apologised," it added.
Iranian state television later released footage of one of the detained men, identified as a U.S. navy commander, apologising for the incident.
"It was a mistake, that was our fault, and we apologise for our mistake," the sailor said on IRIB state TV.
U.S. Vice President Joe Biden rejected reports Washington had offered Iran an apology over the incident.
"No, there was no apology, nothing to apologise for ... and there's no looking for any apology," Biden said on CBS's 'This Morning' programme.
A carefully worded statement did not explain how the sailors and their two riverine command boats ended up being detained by Iran, saying only that "the Navy will investigate the circumstances that led to the sailors' presence in Iran".
The sailors were later taken ashore by U.S. Navy aircraft, while other sailors took charge of the boats and headed towards Bahrain, their original destination.
The Pentagon said there were no indications the sailors were harmed while in Iranian custody.
U.S. Defense Secretary Ash Carter said he was pleased the sailors had been freed and appreciated "the timely way in which this situation was resolved".
He added: "I want to personally thank Secretary of State John Kerry for his diplomatic engagement with Iran to secure our sailors' swift return."
Kerry thanked Iran for its cooperation in the release of the sailors.
"I think we can all imagine how a similar situation might have played out three or four years ago, and the fact that today this kind of issue can be resolved peacefully and efficiently is a testament to the critical role diplomacy plays in keeping our country safe, secure, and strong," Kerry said.
Kerry spoke to Iranian Foreign Minister Mohammad Javad Zarif several times as the United States sought to win the release of the sailors, a U.S. official said.
Zarif said on twitter that he was "happy to see dialogue and respect, not threats and impetuousness, swiftly resolved the sailors episode".
Four photographs published by Shargh Daily, a Tehran newspaper, and posted on Twitter, purportedly show the moments after one of the U.S. boats was stopped by the IRGC.
Iranian state television released footage of the arrest, showing the sailors as they knelt down with hands behind their heads and their two vessels being surrounded by several IRGC fast boats.
The video showed weapons and ammunition confiscated from the sailors, who were seen eating food provided by the Iranians. There were also images of American passports being inspected.
The incident raised tensions between Iran and the United States, which, along with other world powers, reached a deal last year under which Iran will curb its nuclear activities in exchange for the lifting of economic sanctions.
Some conservatives in both countries, enemies since Iran's 1979 Islamic revolution, have criticised the deal that is due to be implemented in the coming days.
Iran's armed forces chief, Major General Hassan Firouzabadi, said the incident should demonstrate Iranian strength to "troublemakers" in the U.S. Congress, which has sought to put pressure on Iran after the nuclear deal.
And at a presidential campaign rally in the United States, Republican front runner Donald Trump, who accuses President Barack Obama of being weak on foreign policy, described the detention of the sailors as "an indication of where the hell we're going".
A senior U.S. defence official said the circumstances surrounding the incident were still not entirely clear.
"We haven?t been able to fully debrief the sailors," the official said, adding the U.S. military hoped to do so within hours. The sailors were headed to a U.S. military facility in Qatar.
"They?re going through what always happens in these cases, they'll get a medical evaluation, and there will be a debriefing."
Attributing the boats' incursion into Iranian waters to a navigation error marked a de-escalation in rhetoric. Earlier, the Guards had said the boats were "snooping" in Iranian territory and Zarif had demanded an apology from Washington.
The IRGC, the Islamic Republic's praetorian guard, is highly suspicious of U.S. military activity near Iran's borders and many senior officers suspect Washington of pursuing regime change in Tehran.
The Guards operate land and naval units separate to the regular armed forces and stage frequent war games in the Gulf, which separates Iran from its regional rival Saudi Arabia and a U.S. naval base in Bahrain.
Last month, the U.S. Navy said an IRGC vessel fired unguided rockets near the aircraft carrier USS Harry S. Truman in the Strait of Hormuz, a critical shipping route for crude oil that connects the Gulf to the Indian Ocean. Iran denied the vessel had done so.
In April 2015, the Guards seized a container ship belonging to Maersk, one of the world's major shipping lines, in the Gulf because of a legal dispute between the company and Iran. The ship and its 24 crew members were released after 10 days.
The Guards have also seized British servicemen on two occasions, in 2004 and 2007, and a civilian British yacht crew in 2009. On each occasion the sailors were released unharmed.
Iran said the British sailors were released when their government apologised to Iran, but London denied that it had offered any apology.
(Reporting by Bozorgmehr Sharafedin, Susan Heavey, Phil Stewart and Jonathan Landay; Writing by Sam Wilkin; Editing by Sami Aboudi, Peter Graff, Giles Elgood, Peter Millership and Philippa Fletcher)