Two Iranian diplomats detained by U.S. troops in Iraq were released early Friday in Baghdad, Iran's state-run television and news agency reported.

The Iranians were in Iraq on the invitation of Iraqi President Jalal Talabani, officials have said. Their detention was announced on Monday.

The two were handed over to Iranian officials in the presence of Iraq's National Security Adviser Mouwafak al-Rubaie, Iran's state-run news agency, IRNA, reported.

For more on Iraq, click here.

Hassan Kazemi Qomi, Iran's ambassador to Baghdad, said the arrest of the two diplomats was against internationally accepted regulations, IRNA said.

"Fortunately with the effort exerted by the Iraqi officials, the U.S. forces, who first denied their arrest, were obliged to admit it and under pressure from the Iraqi government to release them," IRNA quoted Qomi as saying. Iran did not provide any more information about the diplomats and their release.

The U.S. military and the U.S. Embassy in Iraq said they could not immediately comment.

The White House earlier this week said that U.S. troops detained at least two Iranians and released two others who had diplomatic immunity. A White House spokesman has said the Iranians were taken into custody during a routine raid on suspected insurgents.

Maryam Rajavi, the head of the National Council of Resistance of Iran — an Iranian opposition group — on Thursday in Brussels, Belgium said two Iranians detained by U.S. forces in Iraq were senior members of Iran's elite Revolutionary Guards and allegedly had coordinated attacks against coalition troops and Iraqi civilians. It was not possible to independently verify Rajavi's allegations.

Iran, a Shiite Muslim country, has considerable influence among Iraq's Shiite majority. The United States has accused Iran of supplying money, weapons components and training to Shiite militia in Iraq, as well as technology for roadside bombs. Iran has denied the allegations, saying it only has political and religious links with Iraqi Shiites.

Talabani last month visited Iran to seek government officials' help in quelling the sectarian violence in Iraq. The Iraqi president, who is a member of Iraq's Kurdish minority, has had close ties with Iranian officials before Saddam Hussein was overthrown by the U.S.-led invasion in 2003.

For more news on Iran, click here.