TEHRAN – Iran's reformist opposition leaders vowed to press on with legal challenges to an election they say was rigged, even as the hardline government appeared on Thursday to have largely crushed mass street protests.

EDITORS' NOTE: Reuters and other foreign media are subject to Iranian restrictions on their ability to report, film or take pictures in Tehran.

The unrest has exposed unprecedented rifts within Iran's clerical establishment, with Supreme Leader Ayatollah Ali Khamenei, who normally stays above the political fray, siding strongly with anti-Western President Mahmoud Ahmadinejad.

The turmoil in Iran has also put back prospects for U.S. President Barack Obama's hoped for engagement with Tehran over its nuclear program, with Ahmadinejad's government blaming Britain and the United States for fomenting violence.

Iran's tough security crackdown has also led Obama to ramp up his previously muted criticism of Iran, with the president saying he was appalled and outraged by the violence.

Khamenei has declared the result of the June 12 presidential election that returned Ahmadinejad would stand and said opposition leaders would be held responsible for any bloodshed.

Some 20 people have been killed in the demonstrations, but police and militia have largely succeeded in taking back control of the streets this week after the most widespread anti-government protests since the 1979 Islamic revolution.

Riot police swiftly dispersed a group of about 200 demonstrators with teargas on Wednesday, but the protest was a far cry from marches last week that attracted tens of thousands.

Protest cries of Allahu Akbar (God is Greatest) were heard from Tehran rooftops again overnight, although they were much more short-lived than on previous evenings in the capital.

But opposition leaders, though they appeared to have lost the weapon of public protest, were still unbowed.

Reformist cleric Mehdi Karoubi, who came last in the election, called the new government illegitimate and the wife of Mirhossein Mousavi, who says he won the poll, said it was a duty to continue legal protests to preserve Iranian rights.

Mousavi is backed by influential former President Akbar Hashemi Rafsanjani, a pragmatist who favors a less confrontational foreign policy who heads a council of clerics which in theory at least has the power to depose Khamenei.

Mousavi and Rafsanjani met senior parliamentarians on Wednesday. The semi-official Fars news agency said only that the election and latest developments were discussed and it was not clear whether the pair were trying to make peace with the hardline-dominated parliament or trying to win support.

PRESSURING IRAN

Having lost the avenue of street demonstrations, Mousavi supporters said they planned to release thousands of balloons on Friday imprinted with the message Neda you will always remain in our hearts -- a reference to a young woman killed last week whose image has become an icon of the protests.

Mousavi says the election should be annulled but Iran's top legislative body, the Guardian Council, has ruled this out.

A spokesman for the council, which must approve the poll, said it had looked into all complaints but found no major fraud or irregularities, state Press TV reported on Thursday.

The spokesman said the vote was among the healthiest elections ever held in the country since the 1979 Islamic revolution, said Press TV.

The television said eight of those killed in the post-vote unrest were pro-government militia members.

The United States withdrew invitations to Iranian diplomats to attend U.S. Independence Day celebrations on July 4.

It was the first time since Washington cut diplomatic ties with Tehran in 1980 that Iranian diplomats had been invited to the embassy parties, but the move to withdraw the invites was largely symbolic as no Iranians had even responded.

The president's policy of engagement is obviously delayed, but we are going to have to deal with the government of Iran, Senator John Kerry, chairman of the influential Senate Foreign Relations Committee, told Reuters.

The best U.S. option for pressuring Iran, the world's fifth biggest oil producer, was to drive down crude prices by reducing America's dependence on imported energy, Kerry said.

Iran said it was weighing whether to downgrade ties with Britain after each country expelled two diplomats this week and Tehran's foreign minister announced he had no plans to attend a G8 meeting in Italy this week on Afghanistan.

Russia meanwhile said it was sure Iran's election dispute was being resolved according to the law.

We're confident that all issues that arise in connection with the elections will be decided in accordance to the laws of Iran ... and as we understand that, this is happening, Interfax news agency quoted Foreign Minister Sergei Lavrov as saying.

(Additional reporting by Zahra Hosseinian and Hossein jaseb; writing by Jon Hemming; Editing by Ralph Gowling)