TEHRAN- Two losing contenders in Iran's presidential election denounced the result on Wednesday in clear defiance of Supreme Leader Ayatollah Ali Khamenei, saying Mahmoud Ahmadinejad's next cabinet would be illegitimate.

Moderate former prime minister Mirhossein Mousavi and reformist cleric Mehdi Karoubi unleashed fierce attacks on the outcome of the June 12 vote that returned Ahmadinejad to power as president for a second term.

Pro-reform ex-president Mohammad Khatami also criticized the vote and the mass arrests of demonstrators that followed, declaring in a hard-hitting statement: Oppressing people will not help end the protests.

Although hardliners have appeared to be in the driving seat since security forces overcame street protests that erupted in the days after the poll, Mousavi and Karoubi have not yielded.

Both men issued statements on their websites describing Ahmadinejad's future government as illegitimate -- even though Khamenei, the Islamic Republic's ultimate arbiter, has upheld the result and thrown his weight behind the president.

It is our historic responsibility to continue our protests and not to abandon our efforts to preserve the nation's rights, Mousavi wrote, urging the release of children of the revolution -- meaning scores of reformist political figures rounded up during Iran's gravest unrest since the shah fell in 1979.

Karoubi, a reformist former parliament speaker who came last in the poll, also pledged to fight on. I don't consider this government legitimate, his statement said.

Visible and invisible forces blocked any change in the executive power, he said, demanding the release of the thousands of people he said had been arrested since the poll.

Iran's police chief, Ismail Ahmadi-Moghaddam, put the total number of detainees at 1,032 and said most had been freed. The rest were referred to the public and revolutionary courts, the semi-official Fars news agency quoted him as saying. He said 20 rioters had been killed and more than 500 police injured.

COUP D'ETAT

A leading reformist party said the election had been a coup d'etat that harmed the legitimacy of the establishment.

We openly announce that the result is unacceptable, said a statement by the Islamic Iran Participation Front, established by reformers close to Khatami.

In his statement, the former president demanded of the authorities: If you want to calm the atmosphere, why are you carrying out mass arrests?

Addressing the judiciary, he said: If these people have committed crimes, why are their legal rights as citizens not preserved, why don't they have access to a lawyer, why are they not tried in a court, why haven't they been charged?

Khatami added: Obtaining confessions in front of cameras is a useless old method ... confessions under pressure are not valid.

Ahmadinejad canceled a trip to Libya for an African Union summit that would have given him another chance to burnish his image at a potentially friendly international forum.
His office gave no reason for the decision but a Foreign Ministry spokesman said the president was too busy to go.

Four days after the vote, Ahmadinejad attended a regional summit in Russia in a show of confidence, ignoring mass rallies against a process that Mousavi and Karoubi say was rigged.

Iran has accused foreign powers, especially Britain and the United States, of inciting the anti-government protests.

Stung by European Union criticism of the election aftermath, Iran's top military commander demanded that the 27-nation bloc say sorry for its interference before any resumption of talks on Tehran's disputed nuclear program.

Before apologizing for their huge mistake ... they have no right to talk about nuclear negotiations, Major-General Hassan Firouzabadi was quoted by Fars as saying.

NUCLEAR TALKS

The EU powers Britain, France and Germany have led negotiations with Iran over nuclear work that the West suspects is aimed at bomb-making. Tehran says it is wholly peaceful.

Together with the United States, Russia and China, the EU nations have offered a package of economic and other incentives to Iran if it will stop enriching uranium, a process that can produce fuel for power plants, or, potentially, a nuclear bomb.

Iran has rejected the demand, saying it has the right to pursue such work as a member of the Non-Proliferation Treaty.

U.S. President Barack Obama's administration had offered to join the negotiations, but the turmoil after the election has dimmed prospects for any American engagement with Tehran.

A row between Iran and Britain rumbled on, with the Fars agency alleging that an Iranian employee at the British embassy had helped foment the street protests.

The authorities detained nine Iranian employees at the British embassy on Sunday, but all but two have been freed, according to a British embassy source.

Fars said one of those held had a remarkable role during the recent unrest in managing it behind the scenes. It said another employee had been a main element behind the riots but had been freed because she had diplomatic immunity.

Britain strongly denies embassy staff helped whip up the protests. Foreign Secretary David Miliband said the detentions and the previous expulsion of two British diplomats were completely contrary to the sort of good political engagement that Iran says that it wants.

He said the violence the Iranian government had perpetrated against its people since the election was shocking. In the modern world, the truth will out and I hope that it comes out before too many more bones are broken and lives lost in Iran.

Swedish Foreign Minister Carl Bildt said Iran and the EU shared an interest in protecting diplomatic staff.
Asked whether there was a recommendation for EU countries to withdraw ambassadors from Tehran, he told Reuters: We are taking one step at a time. At the moment we are in a state of dialogue with the Iranian authorities about these issues.

(Writing by Alistair Lyon; Editing by Mark Trevelyan)