BAGHDAD (Reuters) - The US military has handed Iraqi authorities five Iranians it had been holding in Iraq, and Iraqi officials said the men would be delivered to Iran on Thursday. The capture of the Iranians, who include officials US forces accused of arming the militias at the height of Iraqs sectarian war, stoked tension between Tehran and Washington, also at odds over Irans disputed nuclear programme. In compliance with the US-Iraq security agreement, the US has turned over five Iranian detainees at the request of the Iraqi government, the White House said in a statement. Iranian FM spokesman Hassan Qashqavi told state television the five would be handed over to the Iranian embassy in the next hours. Under a bilateral security pact that took effect in January, the US must gradually transfer more than 10,000 detainees it still holds to the Iraqi govt to be either charged in local courts or released. A vast prison camp in S Iraq, and a smaller one near Baghdad airport, will be closed or handed to Iraq, ending a controversial program of detention without charge that has been a feature of the US presence in Iraq during 6 yrs of war. Iranian state television said three of the men were diplomats detained in a 2007 US raid in Iraqs northern city of Arbil, while the rest were two other Iranians kidnapped elsewhere in Iraq by the US occupation troops. Five men were originally detained in Arbil in 2007, but two of them were later released. There was no further information about the additional two Iranians released on Thursday. The Iraqi government confirmed the men had been received into Iraqi custody. US President Barack Obama has been trying to improve ties with Iran since he took office in January, offering a new beginning in ties if Iran unclenches its fist. But last months disputed presidential election in Iran has again frayed relations between Iran and the West, with Iranian officials accusing the United States and Britain of interfering in its internal affairs. The Iranians were detained in Arbil on suspicion of being members of the Iranian Revolutionary Guards elite Qods force, which Washington says backs terrorists. Washington has long accused Iran of fomenting violence in Iraq by arming, funding and training special groups, and tasking them with attacking US troops or Sunni Muslim targets. Iran rejects the charge and instead says the United States is to blame for the years of sectarian slaughter and insurgent violence that almost tore Iraq apart after the 2003 US-led invasion. Qashqavi, the Foreign Ministry spokesman, said the five were diplomats who had been held contrary to all international conventions. He said they had been in contact with their families and the Iranian embassy after being transferred to Iraqi custody.