The alleged pirates are accused of trying to hijack a cargo ship when the Iranian navy, which had been conducting anti-piracy patrols in the region, engaged the men more than 1,800 miles outside Iran's territorial waters.

The ship had been bound for Iran before the clash, which lasted about 48 hours, according to the news agency.

Since 2008, the country's navy has been conducting anti-piracy patrols in and around the Gulf of Aden.

The detained alleged pirates have since been transferred to Iran, the agency reported.

Piracy has flourished off Somalia's coast, which has not had an effective government for two decades.

Analysts say that while international navies combating piracy have been fairly successful in setting up a patrolled transit corridor through the Gulf of Aden, shifting pirate activities into the southern Red Sea, Indian Ocean and the Arabian Sea continue to pose shipping hazards.