The US military has admitted to what it called a "regrettable incident" after it arrested a group of eight Iranians in Baghdad.
The Iranians were held at a checkpoint and detained overnight. They were freed after the Iraqi government intervened.
Iran says the men were in the city at the invitation of Iraq's government, and that the US action was unjustified.
An aide to the top US commander in Iraq later said the US accepted that the Iranians were on official business.
Dr Saadi Othman, adviser to Gen David Petraeus, told BBC News that the incident had "nothing to do" with US President George W Bush's speech on Tuesday, in which he strongly criticised Iran for its alleged interference in Iraq.
The Iranians were detained after they had been stopped in the company of seven Iraqis carrying unauthorised weapons on Tuesday night, the US military said.
It said an AK-47 assault rifle and two pistols were confiscated from the Iraqis. The group was then taken to the Sheraton Ishtar Hotel, where US troops searched the Iranians' rooms, seizing a computer, mobile phones and a briefcase full of money.
The men were also taken away for questioning, with video footage showing soldiers leading them out blindfolded and in handcuffs.
All the Iranians were later handed over to the Iraqi government.
It later emerged that the men were energy experts and were in the Iraqi capital to help rebuild the local electricity system. Two of them were found to have diplomatic credentials.
Iran has said it is preparing a formal protest to Iraq.
The arrests followed President Bush's speech, in which he criticised Iranian interference in Iraq.
Tensions between the US and Iran are running high, with the US accusing Iran of providing arms, money and military training to Shia militias in Iraq.
President Bush stated that he had authorised his military commanders in Iraq to confront what he called Iran's "murderous activities" in the country.
"Iran's actions threaten the security of nations everywhere. We will confront this danger before it is too late," Mr Bush said.
The president also said the entire region would be under the shadow of a "nuclear holocaust" if Iran developed nuclear weapons. Tehran insists its nuclear programme is peaceful.
Earlier on Tuesday, Iranian President Mahmoud Ahmadinejad said US power in Iraq was on the verge of collapse and this would lead to "a huge vacuum" which Iran would be willing to fill.
In January, five Iranians - who the US said were linked to Iran's Revolutionary Guard and were training militants in Iraq - were captured in the northern city of Irbil. They remain in US custody.