Iran on Wednesday freed 10 American sailors from two small Navy vessels that Tehran claimed strayed into Iranian waters, prompting their overnight detention as Washington opened direct contacts with Iran seeking their release.

A senior defense official, speaking in Washington, said the sailors were not harmed but would undergo medical evaluation and a debriefing in the Persian Gulf nation of Qatar. Meanwhile, their vessels were taken by another American crew to Bahrain, their original destination and home to the U.S. Navy’s 5th Fleet.

The release appeared to end a potential flash point as Iran and world powers move toward the possible next steps in a landmark nuclear deal that limits Tehran’s atomic program in exchange for the easing of international economic sanctions.

Iran released video on Wednesday, Jan. 13, of 10 U.S. sailors who were detained by Iran overnight aboard their two U.S. Navy patrol boats in the Persian Gulf. (Reuters)

The detention also added to tensions in the Persian Gulf region amid the worst diplomatic unraveling in decades between Shiite power Iran and Saudi Arabia and its Sunni allies. The feud — opened by Saudi Arabia’s execution of a prominent Shiite cleric earlier this month — has put Washington in the middle as it seeks to implement the nuclear deal while also backing its key regional partner, Saudi Arabia.

“Ten U.S. Navy Sailors safely returned to U.S. custody today, after departing Iran,” said a statement from U.S. Naval Forces Central Command. “There are no indications that the Sailors were harmed during their brief detention.”

According to the Navy’s statement, the sailors departed Farsi Island, where they were held, at 8:43 a.m. GMT (3:43 a.m. EST) on board the same boats that were intercepted. They were picked up by Navy aircraft and transferred ashore, eventually ending up in Qatar, while other sailors took charge of the vessels, called riverine command boats, and continued to Bahrain.

Secretary of State John Kerry said he was "pleased" by the safe release of U.S. sailors from Iranian custody Jan. 13. (Reuters)

The sailors will receive support to reintegrate with their unit, said Cmdr. Kevin Stephens, a spokesman for the 5th Fleet. He declined to provide details on the identities of the 10 sailors, reportedly including one woman. Stephens said the Navy’s priority now is “determining … how exactly these sailors found themselves in Iran. And that’s something we’re going to be looking at.”

Iranian and U.S. ships often come within hailing distance in the Persian Gulf during patrols and maneuvers. The gulf is also the route for more than one-fifth of the world’s oil tanker traffic through the Strait of Hormuz, which is jointly controlled by Iran and Western-ally Oman.

Secretary of State John F. Kerry, in a statement, expressed his “gratitude to Iranian authorities for their cooperation in quickly resolving this matter…. That this issue was resolved peacefully and efficiently is a testament to the critical role diplomacy plays in keeping our country safe, secure, and strong.”

The incident, meanwhile, offered a test of new high-level channels opened during the nuclear talks between the two nations. Diplomatic relations between Washington and Tehran soured after Iran’s 1979 Islamic revolution, and they were formally severed in April 1980, five months after militants seized the U.S. Embassy in Tehran and took Americans hostage.

For hours — even as President Obama gave his annual State of the Union address — messages passed directly between Iran and Washington instead of the intermediary nations used for decades. The exchanges included Kerry reaching out to Iranian Foreign Minister Mohammad Javad Zarif, who was Iran’s point man during the nuclear talks, said a senior U.S. official, who was not authorized to discuss the matter publicly and spoke on condition of anonymity.

Kerry “made the case very strongly” to Zarif that the incident had stemmed from a mechanical problem aboard one of the boats and that they appeared to have drifted into Iranian territorial waters, the official said.

Zarif asked for more information about the incident, which the State Department later communicated to Iran. Zarif, the official said, “came back and said they were all safe and sound, that nobody was hurt,” and that Iran would “return them promptly.”

Iran’s Fars News Agency quoted a statement from the country’s powerful Revolutionary Guard Corps saying the sailors were released after “investigations showed that they had gone astray during their voyage in the Persian Gulf.” In its statement, the Guard added that the “illegal entry into Iranian water was not the result of a purposeful act.”

The quick moves by the Revolutionary Guard also suggested that Iran’s supreme leader, Ayatollah Ali Khamenei, sought to keep the detention from overshadowing regional affairs, including the nuclear deal.

Video of the seizure, however, indicated tense moments. The U.S. crew is shown kneeling on the deck with their hands behind their heads. Other images, broadcast by Iranian state television, included the sailors sitting on the floor in a carpeted room, and an apparent Iranian official examining their American passports.

“After it became clear that the U.S. combat vessels’ illegal entry into the Islamic Republic of Iran’s waters was the result of an unintentional action and a mistake and after they extended an apology, the decision was made to release them,” the Revolutionary Guard’s statement said.

“The Americans have undertaken not to repeat such mistakes,” it added. “The captured marines were released in international waters under the supervision of the IRGC Navy.”

But State Department spokesman John Kirby said there was “zero truth” to reports of a formal U.S. apology, citing only Kerry’s expression of thanks to Iranian officials.

“Nothing to apologize for,” Kirby wrote in a tweet.

The exact circumstances surrounding the incident remained unclear.  

The two small boats, used largely on coastal waters and on rivers, had been en route from Kuwait to Bahrain in the Persian Gulf when they disappeared from the Navy’s scopes. Senior administration officials said the vessels appeared to have experienced mechanical trouble or ran out of fuel, but Fars said the sailors had been “snooping.”

The Iranian military took the boats and their crews to Farsi Island, where Iran maintains a naval base.

The run-in, which in the United States drew calls for reprisal from Republican lawmakers and candidates, came at a sensitive time. Economic sanctions against Iran could be lifted as soon as this month under the nuclear deal.

The incident marked the latest encounter between Iranian and U.S. crews. In December, Iranian gunboats fired unguided missiles about 1,000 yards from the aircraft carrier USS Harry S. Truman.

A U.S. defense official said the small boats were believed to have been within 12 nautical miles of Iran on Tuesday when they broke down. Many officials stressed, though, that it is unclear exactly what happened.

The vessels are agile and often carry Special Operations forces into smaller bodies of water.

Defense Secretary Ashton B. Carter was updated throughout Tuesday afternoon about the incident and spoke with Kerry and national security adviser Susan E. Rice.

In recent weeks, U.S. lawmakers have called for increased sanctions on Iran after the country tested two ballistic missiles in recent months. Since the tests, President Hassan Rouhani vowed to expand the country’s ballistic missile program.

Even though details about the incident were sparse, former Florida governor Jeb Bush, a Republican presidential candidate, had quickly weighed in, accusing President Obama of having a “humiliatingly weak Iran policy.”

Sen. Tom Cotton (R-Ark.), who opposed the nuclear deal, said on CNN that “this kind of openly hostile action is not surprising. It’s exactly what I and so many others predicted when President Obama was negotiating the nuclear deal with Iran — that it would embolden their aggression towards the United States and our allies in the region.”

In 2007, Iran held 15 British Royal Navy personnel for nearly two weeks. Iran claimed the ship entered its territorial waters off the Iran-Iraq coast. Britain said the vessel never left seas under Iraqi control.

Carol Morello, Brian Murphy and Karen DeYoung contributed to this report.