Iran's Islamic Revolutionary Guard Corps (IRGC) said it had released the sailors after determining they had entered Iranian territorial waters by mistake. IRGC Rear Admiral Ali Fadavi said the boats had strayed because of a broken navigation system.

There were no indications the sailors were harmed while in Iranian custody, the Pentagon said. The quick resolution contrasted with previous cases in which British servicemen were held considerably longer, in one case nearly two weeks.

Iran expects the U.N. nuclear watchdog to confirm on Friday it has curtailed its nuclear programme, paving the way for the unfreezing of billions of dollars of Iranian assets and an end to bans that have crippled oil exports.

In a statement carried by state television, the IRGC said the sailors were released in international waters after they apologised.

Iranian state television later released footage of one of the detained men, identified as a U.S. Navy commander, apologising for the incident.

"It was a mistake, that was our fault, and we apologise for our mistake," the sailor said on IRIB state TV.

A Pentagon spokesman, Commander Gary Ross, said the video appeared to be authentic, "but we cannot speak to the conditions of the situation or what the crew was experiencing at the time."

A U.S. defence official, speaking on condition of anonymity, said: "Clearly this staged video exhibits a sailor making an apology in an unknown context as an effort to defuse a tense situation and protect his crew."

U.S. Vice President Joe Biden earlier rejected reports that Washington itself had offered Iran an apology over the incident.

The incident spilled over into the U.S. presidential campaign, where Republicans are critical of the nuclear deal Iran forged with six world powers and due to take effect soon.