The arrests sparked a row between Washington and Tehran
Five Iranian officials held by the US military in Iraq since January 2007 have been handed to Iran's embassy.
US forces seized the five in the northern city of Irbil on suspicion of arming and funding Shia militias.
Iran says they are diplomats. Its embassy said it had received the men, who were first moved to Iraqi custody.
The US state department said the release was not part of a deal with Tehran, but was necessary under a US-Iraqi security pact.
Under a key security agreement with the Baghdad government, the US military, which holds thousands of people in jails in Iraq, is obligated to hand all detainees to Iraqi control.
The US state department denied that the release was a goodwill gesture or part of an exchange deal for the release of journalist Roxanna Saberi, freed from an Iranian jail in May.
The US has been attempting to engage Iran diplomatically in the hope of persuading it to abandon its alleged nuclear weapons programme.
A US state department spokesman said the five freed officials were "associated with" Iran's Quds force, an elite unit of the Revolutionary Guards.
Washington accuses the force of helping to arm and train some Iraqi militants, a claim Tehran denies.
The spokesman said the possibility that the five might create security problems in Iraq was "a big concern".
Iran's ambassador in Iraq, Hassan Kazemi-Qomi, described the men as "diplomats" and said they were in good mental health but awaiting physical medical examination, in an interview with state radio.
After the arrests, Washington said the five Iranians had no diplomatic status, but Tehran accused the US of breaching international diplomatic regulations.
The Iraqi authorities said at the time the five Iranians had been in Irbil with official approval, but that their office had not yet been granted full consulate status.