The US military in Iraq has released nine of the 20 Iranian citizens it has detained there, including two held on suspicion of helping Shia militants.
Two of the men were seized near the Iranian consulate in Irbil
The release followed a review of their cases which concluded that the men no longer posed a security risk and were "of no continued intelligence value".
The Iranians were released to the Iraqi government, which later reportedly gave them to the Iranian embassy in Baghdad.
Tehran has dismissed US accusations that it is aiding insurgents in Iraq.
In October, the US declared the overseas operations arm of the Iranian Islamic Revolution Guards Corps (IRGC) a "supporter of terrorism", saying it was supplying and training Shia militants in Iraq.
Two of those freed on Friday were among five Iranian officials detained by US forces in an "intelligence-driven raid" on an office in the same building as the Iranian consulate in the Kurdish city of Irbil in January.
Their detention has been the subject of intense protests by the Iranian government and lobbying by Iraqi authorities.
The Kurdistan Regional Government (KRG) also objected, saying the office and its personnel were known to them.
The other seven Iranians being freed had been picked up in different parts of the country and held for periods ranging between three months and three years.
The US military said two of the men were captured "during a raid to disrupt al-Qaeda operations", while another was held after a raid "aimed at capturing a senior insurgent".
"The release followed a careful review of individual records to determine if they posed a security threat to Iraq, and if their detention was of continued intelligence value," the military said in a statement.
"Based on this review, all nine individuals were determined to no longer pose a security risk and to be of no continued intelligence value."
After the men were transferred by Iraqi authorities to the Iranian embassy, they were driven to Baghdad International Airport for a flight to Tehran, the Iranian official news agency, IRNA, reported.
The BBC's Jim Muir in Baghdad says the releases, although they leave a further 11 Iranians still in detention, might be seen as heralding something of a thaw between the US and Iran - at least in Iraq.
US military commanders have hinted they are beginning to sense a greater effort by Iran to stop weapons and explosives crossing the border, our correspondent says.
The release of the nine Iranians was welcomed by Iraq's Foreign Minister, Hoshyar Zebari, who said it was a " positive development".
He hoped it would improve the prospects for another trilateral meeting with the US and Iran this month on security and stability in Iraq.
Both Washington and Tehran have said they are willing in principle. There have been several previous meetings, held at the request of the Iraqi government.