Iran has demanded that the US military immediately release five of its nationals detained in a raid in northern Iraq on Thursday.

Iran's foreign ministry says the men are diplomats and were working at the Iranian liaison office in Irbil.

US officials say they are linked to the Iranian Revolutionary Guard which they say trains and arms Iraqi insurgents.

The US has the authority to pursue Iranians in Iraq who "put our people at risk", a top US official has said.

"We are going to need to deal with what Iran is doing inside Iraq," said National Security Adviser Stephen Hadley on Sunday.

"We know there are jihadists moving from Syria into Iraq. ...We know also that Iran is supplying elements in Iraq that are attacking Iraqis and attacking our forces," he told ABC Television.

Tough stance

If Iranians in Iraq "are doing things that are putting our people at risk, of course we have the authority to go after them and protect our people," Mr Hadley said.

The US has often accused Iran, or factions within the Iranian government, of aiding Shia groups in Iraq militarily and politically, but has offered little proof of Tehran's alleged activities.

The latest raid followed a warning by President George W Bush on Wednesday that the US would take a tough stance towards Iran and Syria, whom he accused of destabilising Iraq.

Tehran vehemently denies the charges.

Iran's foreign ministry has said the detained men were "involved in consulate affairs".

"Their activities were legal and in the framework of the law," Iranian Foreign Ministry spokesman Mohammad Ali Hosseini said in response to the allegations.

The Iranian government has also demanded compensation for damage to the building where the men were seized.

'Illegal action'

Mr Hosseini said the building the Americans attacked opened in 1992 and was officially registered as the Iranian consulate. The Iraqi authorities have said it was a liaison office in the process of being registered as a consulate.

Iran is adamant the office and the staff inside should have had diplomatic protection and that America's action was illegal.

"What the Americans claim is incorrect. The Americans want to radicalise the atmosphere in Iraq to justify their occupation, but we will act wisely," he said.

Tehran has protested to the ambassadors of Iraq and Switzerland, which represents American interests in Iran.

Last month several Iranians were arrested by the US in Baghdad, among them two senior Revolutionary Guard officers. They were released after huge pressure from the Iraqi government.

The Revolutionary Guard, known locally as the Pasdaran, is a parallel military force with its own army, air force and navy.

It was set up to enforce and defend the principles of the 1979 Islamic revolution and answers directly to Supreme Leader Ayatollah Ali Khamenei.