Update on January 13 at 12:40 p.m. ET

U.S. and Iranian officials are hailing the diplomacy that resulted in the release by Iran of 10 Navy sailors and their two boats that inadvertently strayed into Iranian waters.

“I want to express my gratitude to Iranian authorities for their cooperation ‎in swiftly resolving this matter,” John Kerry, the U.S. secretary of state, said in a statement. “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.”

Mohammed Javad Zarif, his Iranian counterpart, tweeted:

Earlier Wednesday, Iranian and U.S. officials announced that Iran had freed the sailors and their vessels, which had been en route Tuesday to Kuwait from Bahrain on a routine exercise. A senior defense official said contact was lost with the boats Tuesday. Iran said they were detained and held at a base on Farsi Island.

A statement from Iran’s Islamic Revolution Guards Corps said “technical and operational examinations” of the vessels showed they had inadvertently entered Iranian waters and were released into international waters after an apology. Rear Admiral Ali Fadavi, the commander of the IRGC Navy, said earlier Wednesday the U.S. vessels had developed technical problems with their navigation systems.  (You can watch them being released here, courtesy of the AP.)

The sailors left Farsi Island at 8:43 a.m. GMT aboard their two boats and were picked up by Navy aircraft. Their boats are being returned to Bahrain, home to the U.S. Fifth Fleet.

The U.S. Navy said the American sailors—nine men and a woman—had returned safely; there were no indications they had been harmed, the Navy said.

“The Navy will investigate the circumstances that led to the sailors’ presence in Iran,” the statement said.

Here’s more from the AP about the sailors and their vessels:

The sailors were part of Riverine Squadron 1 based in San Diego and were deployed to the U.S. Navy's 5th Fleet in Bahrain. When the U.S. 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.

The Riverine boats were not part of the carrier strike group, and were on a training mission, the officials said. The craft are not considered high-tech and don't contain any sensitive equipment, so there were no concerns about the Iranians gaining access to them, they added. The officials spoke on condition of anonymity because they were not authorized to discuss the sensitive incident publicly.

The incident was seen as a test case for newly improved U.S.-Iranian relations. Ties, long frozen after the 1979 Islamic revolution and the subsequent hostage crisis at the U.S. Embassy in Tehran, have begun to slowly thaw. The U.S. and other world powers successfully negotiated with Iran on its nuclear program, and the Islamic Republic is just days away from implementing its end of the nuclear deal—for which it will get much-needed sanctions relief.

The detaining of the Americans could have derailed some of those efforts, but their relatively quick release points to the success of diplomacy. Indeed, the BBC notes the Iranian media had been uncharacteristically measured in its reporting of the American sailors.  

Press TV, the Iranian state-run broadcaster, reported that Zarif, the Iranian foreign minister, had discussed the issue with Kerry and “adopted a strong and firm stance.” A U.S. official, cited by the AP, said Kerry “personally engaged” with Zarif over the incident. The two men had negotiated closely over the nuclear deal, and reportedly developed a rapport during the often tense talks.