Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Ten U.S. sailors detained by Iran were released early Wednesday, officials said.

The sailors — nine men and one woman — were held overnight on Iran's Farsi Island. They were taken into custody Tuesday when their two small U.S. navy riverine vessels drifted into Iranian waters during a training mission.

Iran's Revolutionary Guards (IRGC) said in a statement Wednesday that the sailors had been released back into international waters following a U.S. apology and clarifications that any incursion was "a mistake."

"The Americans have undertaken not to repeat such mistakes," added the statement, which was read aloud on state TV. "The captured marines were released in international waters under the supervision of the IRGC Navy."

The State Department denied that any apology took place — with spokesman John Kirby saying on Twitter there was "nothing to apologize for" — but welcomed news of the sailors' release.

Absolutely ZERO truth to rumors that @JohnKerry apologized to Iran over Sailors. Nothing to apologize for. -John Kirby (@statedeptspox) January 13, 2016

Secretary of State John Kerry during an address Wednesday morning thanked Iranian authorities for their cooperation and “quick response.”

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“All indications (were) that our sailors were well taken care of,” he said, adding that the U.S. and Iran were able to resolve the situation through diplomatic channels.

“I think we can all imagine how a similar situation might have played out three or four years ago, and in fact, that is a testament to the critical role diplomacy plays in keeping our country safe, secure and strong,” Kerry said.

Defense Secretary Ash Carter also said he was "pleased" the sailors were back in U.S. hands, thanking Kerry for his diplomatic efforts to secure their release.

"We appreciate the timely way in which this situation was resolved," he said in a statement which did not address the alleged apology.

The sailors were "safely returned" after departing Iran's Farsi Island at 3:43 a.m. ET aboard the riverine vessels they had been operating when the incident occurred, according to the U.S. Navy.

They were later transferred ashore by Navy aircraft while other sailors took charge of their boats and continued on for Bahrain, the Navy added in a statement.

A handout picture released Wednesday by Iran's Revolutionary Guards shows the detained U.S. vessels. HO / AFP - Getty Images

"There are no indications that the sailors were harmed during their brief detention," the statement said, adding that the circumstances of the incident will be investigated.

The sailors — who were escorted off Farsi Island by Iranian forces — were given medical exams aboard the U.S.S. Anzio before being flown to shore and taken to the American navy base in Bahrain, U.S. military officials told NBC News.

The sailors' release caps a quick, overnight flurry of diplomatic activity after Iran said the boats had entered its waters on Tuesday.

U.S. officials had sprung into action, with Kerry calling his Iranian counterpart Javad Zarif in hopes of securing the sailors' freedom.

Happy to see dialog and respect, not threats and impetuousness, swiftly resolved the #sailors episode. Let’s learn from this latest example. — Javad Zarif (@JZarif) January 13, 2016

Iran's Navy chief Gen. Ali Fadavi initially accused the U.S. Navy vessels of demonstrating "unprofessional behavior." However, later Wednesday he said that an investigation showed the American vessels had entered his country's waters due to a mechanical issue — which jibed with what U.S. officials had initially suggested.

"It was not for espionage or other harmful purposes," Fadavi said on state-run TV.

Still, he defended the decision to take the sailors into custody as "necessary measures" given the presence of U.S. forces in the region.

American naval ships routinely navigate the waters of the Persian Gulf near Iranian territory, and their presence there frequently has been a source of tensions between the two nations.

Senior U.S. military commanders criticized Iran last month for its "highly provocative" actions when it fired unguided rockets near U.S. ships, including the USS Harry S. Truman aircraft carrier, in the Strait of Hormuz.