ANKARA (Reuters) - Iran could contemplate cooperating with its old adversary the United States on restoring security to Iraq if it saw Washington confronting "terrorist groups in Iraq and elsewhere", Iranian President Hassan Rouhani said on Saturday.
Rouhani, a relative moderate who has presided over a thaw in Iran's relations with the West, added that Tehran stood ready to provide help to Iraq within the framework of international law, but so far Baghdad had not requested such assistance.
Shi'ite Muslim Iran has been alarmed by the seizure this week of several major northern Iraqi towns by Sunni Islamist insurgent forces and their sweep southward to within an hour's drive of Baghdad, and not far from the Iranian border.
A senior Iranian official told Reuters earlier this week that Tehran, which has strong leverage in Shi'ite-majority Iraq, may be ready to cooperate with the United States in helping Baghdad fight back against the jihadist ISIL rebels.
"We all should practically and verbally confront terrorist groups," Rouhani told a press conference broadcast live on state television.
Asked if Tehran would work with Washington in tackling advances by Sunni insurgents in Iraq, he replied: "We can think about it if we see America starts confronting the terrorist groups in Iraq or elsewhere."
Fighters of the Islamic State of Iraq and the Levant (ISIL) are bent on recreating a mediaeval caliphate spanning territory they have carved out in fragmenting Iraq and Syria, where it has exploited a power vacuum in the midst of civil war.
The senior Iranian official told Reuters the idea of cooperating with the Americans was being discussed within the Tehran leadership. For now, according to Iranian media, Iran will send Baghdad's Shi'ite-led government advisers and weaponry, although probably not troops, to boost Baghdad.
In Washington, U.S. President Barack Obama said he was reviewing military options, short of sending combat troops, to help Iraq repel the insurgency but warned any U.S. action must be accompanied by an Iraqi government effort to bridge divisions between Shi'ite and Sunni communities.
U.S. officials said there were no contacts going on with Iran over the crisis in Iraq.
Rouhani said Iran would consider any request for help it got from Baghdad, although he was not aware of any American plans for Iraq or whether Washington wanted to help Baghdad.
"If the Iraqi government and nation ask for our help, we will review it. So far there has not been such a request," he said. "We are ready to help in the framework of international regulations and laws."
"We have always helped to secure stability in the region, whether in Afghanistan and elsewhere in the region."
Rouhani said "terrorist groups" were getting financial and political backing and weaponry from some regional countries and some powerful Western states.
He named no countries, but was alluding in part to Sunni Gulf Arabs who Iran suspects has funnelled support to ISIL.
"Where did ISIL come from? Who is funding this terrorist group? We had warned everyone, including the West, about the danger of backing such a terrorist and reckless group."
Gulf Arab governments deny any role in backing ISIL, noting that the group has long battled Saudi Arabia's allies among other Sunni rebel factions in Syria.
Saudi Arabia last month designated ISIL a terrorist organisation, conveying its concern that young Saudis hardened by battle could come home to target the ruling Al Saud royal family - as happened after earlier wars in Afghanistan and Iraq.
(Reporting by Parisa Hafezi; Writing by William Maclean; Editing by Mark Heinrich)