Iranian President Hassan Rouhani speaks during a press conference in the capital Tehran on June 14, 2014. Iran may consider cooperating with the United States in fighting Sunni extremist fighters in Iraq if Washington acts against them, Rouhani told journalists. AFP PHOTO/ATTA KENARE (Photo credit should read ATTA KENARE/AFP/Getty Images)

By Parisa Hafezi

ANKARA, June 14 (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 pragmatist who has presided over a thaw in Iran's relations with the West, also said Tehran was unlikely to send forces to Iraq but stood ready to provide help within the framework of international law. Baghdad has not requested such assistance, he added.

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.

"We all should practically and verbally confront terrorist groups," Rouhani told a news conference broadcast live on state television.

Asked if Tehran would work with Washington in tackling the 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 medieval 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.

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 Washington in helping Baghdad fight back against the jihadist ISIL rebels.

The official said the idea of cooperating with the Americans was being discussed within the Tehran leadership. For now, according to Iranian media, Iran will send advisers and weaponry, although probably not troops, to boost Baghdad.

NOT SENDING TROOPS

"Iran has never dispatched any forces to Iraq and it is very unlikely it will ever happen," Rouhani told Saturday's news conference.

Western diplomats suspect Iran has in the past sent some of its Revolutionary Guards, a hardline force that works in parallel with the army, to train and advise the Iraqi army or its militia allies.

Interior Minister Abdolreza Rahmani Fazli, quoted by Fars news agency, said: "Supporting the Iraqi government and nation does not mean sending troops to Iraq. It means condemning terrorist acts and closing and safeguarding our joint borders."

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 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 added. "We are ready to help in the framework of international regulations and laws."

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 funneled 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 organization, 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 Gareth Jones)