Iran released 10 U.S. sailors on Wednesday after holding them overnight, bringing a swift end to an incident that had rattled nerves days ahead of the expected implementation of a landmark nuclear accord between Tehran and world powers.

Iran's Islamic Revolutionary Guard Corps (IRGC) said it had freed the sailors after determining they had entered Iranian territorial waters by mistake. The sailors had been detained aboard two U.S. Navy patrol boats in the Gulf on Tuesday.

"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 apologized," it added.