Ten US Navy sailors who were taken into custody by Iran on Tuesday after their two small boats drifted into Iranian waters were released on Wednesday morning.
Iran's Islamic Revolutionary Guard Corps (IRGC) said it had freed the sailors after determining they had entered Iranian territorial waters by mistake.
"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.
Confirming the sailors' safe release, the Pentagon said there were no indications they were harmed while in Iranian custody.
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 US Navy aircraft, while other sailors took charge of the boats and headed towards Bahrain, their original destination.
IRGC Rear Admiral Ali Fadavi had earlier said that the two US Navy boats entered Iranian territorial waters due to a broken navigation system.
The Navy chief of the powerful Iranian Revolutionary Guard said Wednesday that the American boats showed "unprofessional acts" for 40 minutes before being picked up by Iranian forces after entering the country's territorial waters.
Gen. Ali Fadavi said the detainees, nine men and one woman, were held overnight at an Iranian base on Farsi Island in the Persian Gulf.
Pentagon spokesman Peter Cook told The Associated Press the Riverine boats were moving between Kuwait and Bahrain when the US lost contact with them.
US officials said that the incident happened near Farsi Island in the middle of the Gulf. They said some type of mechanical trouble with one of the boats caused them to drift into Iranian territorial waters near the island, and they were picked up by Iran.
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.
It set off a dramatic series of calls and meetings as US officials tried to determine the exact status of the crew and reach out to Iranian leaders.
Secretary of State John Kerry, who forged a personal relationship with Iranian Foreign Minister Mohammed Javad Zarif through three years of nuclear negotiations, called Zarif immediately on learning of the incident, according to a senior US official. Kerry "personally engaged with Zarif on this issue to try to get to this outcome," the official said.
Officials said the sailors were part of Riverine Squadron 1 based in San Diego and were deployed to the US Navy's 5th Fleet in Bahrain. When the US lost contact with the boats, ships attached to the USS Harry S Truman aircraft carrier strike group began searching the area, along with aircraft flying off the Truman.
Officials said a radio signal from one of the boats showed that they were on Farsi Island, setting off efforts to contact the Iranians. The Riverine boats were not part of the carrier strike group, and were on a training mission as they traveled between Kuwait and Bahrain, officials said.
The Riverine boats are not considered high-tech and don't contain any sensitive equipment, so there were no concerns about the Iranians gaining access to the crafts.
The incident came on the heels of an incident in late December when Iran launched a rocket test near US warships and boats passing through the Strait of Hormuz.
Meanwhile, Iran was expected to satisfy the terms of last summer's nuclear deal in just days. Once the UN nuclear agency confirms Iran's actions to roll back its program, the United States and other Western powers are obliged to suspend wide-ranging oil, trade and financial sanctions on Tehran. Kerry recently said the deal's implementation was "days away."