Iran released 10 U.S. sailors on Wednesday, after detaining them overnight for allegedly straying into Iranian territorial waters.

Reuters reports Iran's Islamic Revolutionary Guard Corps (IRGC) freed the men after determining that the sailors had entered the waters by accident.

"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, adding that the sailors were let go after they apologized for the mistake.

IRGC Rear Admiral Ali Fadavi explained that the sailors had entered Iranian waters due to a broken navigation system.

Video of the seizure showed the sailors on their knees with their hands behind their heads. Iranian state television broadcasted other images of the men sitting on a carpeted floor as Iranian officials checked their identification and passports.

The announcement is welcome news to many who were concerned the incident would further sully relations between Tehran and the United States, just days before the implementation of a landmark nuclear deal between Iran and several world powers, including the U.S.

According to The Washington Post, a senior defense official in Washington said the soldiers were unharmed in the incident. However, the official added they would have to undergo further debriefing and medical evaluation in Qatar.

The U.S. Navy also released a statement.

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

U.S. Defense Secretary Ash Carter thanked Secretary of State John Kerry, whom he said played an instrumental role in securing the safe release of the sailors.

Kerry, a former U.S. sailor himself, said in a press statement that he was "proud of our young men and women in uniform and know how seriously they take their responsibilities to one another and to other mariners in distress."