Iran's Revolutionary Guard Corps said on Wednesday it has released 10 American sailors who it had detained a day earlier, according to a statement broadcast on state television. A US official has also confirmed that the servicemen have been freed after being held overnight.

This came after the US apparently apologized to Iran, according to General Ali Fadavi, the commander of Iran's Revolutionary Guards naval forces.

Iran detained the sailors aboard two US Navy patrol boats in the Gulf on Tuesday in an incident that rattled nerves days ahead of the expected implementation of a landmark nuclear accord between Tehran and world powers.

Iran's army chief said on Wednesday that the seizure of two boats and their 10 sailors should be a lesson to members of the US Congress trying to impose new sanctions on Tehran.

"This incident in the Persian Gulf, which probably will not be the American forces' last mistake in the region, should be a lesson to troublemakers in the US Congress," Major General Hassan Firouzabadi, head of Iran's armed forces, was quoted as saying by Tasnim news agency.

A US official said the sailors were on board two 38-foot, high-speed vessels called riverine patrol boats, which the US Navy and Marines use to patrol rivers and shorelines. The official suggested that mechanical issues may have disabled one of the vessels, leading to a situation in which both ships drifted inadvertently into Iranian waters.

While both sides appeared eager not to let the incident escalate further, it came at a delicate time for US-Iranian relations, after Iran and six world powers forged a landmark nuclear accord last July. Formal implementation of the accord could begin in days following steps Iran agreed to take to curb its nuclear activities.

This was just the latest reported incident between US and Iranian forces in the Gulf in recent weeks.

The US Navy said late last month that an Iranian Revolutionary Guards vessel fired unguided rockets on December 26 near warships, including the aircraft carrier USS Harry S Truman in the Strait of Hormuz. Iran denied the allegation.

It's also not the first time Iranian forces have detained Western sailors and marines.

In June 2004, Iran arrested six Royal Marines and two naval personnel — part of a US-led force in Iraq — for straying into its waters, stirring diplomatic tensions between the two. The eight were freed three days later.

In March 2007, Iranian forces seized 15 British servicemen — eight Royal Navy sailors and seven marines — in the mouth of the Shatt al-Arab waterway that separates Iran and Iraq, triggering a diplomatic crisis at a time of heightened tensions over Tehran's nuclear ambitions. They were held for 13 days.

In November 2009, Iranian naval vessels detained five Britons on a racing yacht en route from Bahrain to Dubai. They were released a week later.