TEHRAN - Iran's Supreme Leader endorsed the presidency of Mahmoud Ahmadinejad in a ceremony boycotted by leading moderates in protest at a disputed poll that plunged Iran into its worst crisis since the 1979 Islamic Revolution.

Two former presidents, Akbar Hashemi Rafsanjani and Mohammad Khatami, who backed defeated candidate Mirhossein Mousavi, did not attend Monday's ceremony although they had been present at such events in the past, Iranian media reported.

I am endorsing the presidency of this brave, hard-working and wise man as the president of the Islamic Republic of Iran, Supreme Leader Ayatollah Ali Khamenei said, in praise of Ahmadinejad who will be sworn in by parliament on Wednesday.

Witnesses said dozens of riot police and Basij militia assembled at a central Tehran Square after the ceremony to prevent pro-Mousavi supporters from attending a planned protest at 1330 GMT. The gathering was announced by moderate websites.

Other leading moderate figures joined Rajsanfani, who has declared the country in crisis, and Khatami in missing the formal endorsement.

Ahmadinejad's victory to a second term led reformists and moderate candidates Mousavi and Mehdi Karoubi to accuse the government of electoral fraud, caused violent protests and exposed deep schisms within Iran's clerical and political elite.

The president now faces the difficult task of assembling a cabinet which is acceptable to the mostly conservative parliament, which may object if he just picks members of his inner circle. Parliament has in the past rejected some of Ahmadinejad's cabinet choices.

The Supreme Leader endorsed the June 12 election result and demanded an end to the protests at which more than 20 people have been killed, but in a challenge to his authority Mousavi and Karoubi said the next government would be illegitimate.

At the ceremony Khamenei criticized Ahmadinejad's opponents, saying some elites failed (the political test of) the election, state television said.

The president told rivals on Friday that trying to split him from Khamenei was futile because they were like father and son.

Iranian officials have denied any fraud in the election, in which Ahmadinejad was declared to have won 63 percent of 40 million votes cast against 34 percent for Mousavi, in the face of persistent objections by moderates and reformers.

Senior members of Iran's influential Shi'ite clerical establishment have expressed misgivings in the aftermath of the poll in the world's fifth biggest oil exporter which is locked in dispute with the West over its nuclear program.

ROUGH RIDE

Without Khamenei's support, Ahmadinejad's choice of cabinet could run into trouble as a number of lawmakers have been critical of Ahmadinejad's decisions since the vote.

His appointment as vice-president of a man mistrusted by hardliners for remarks on Israel and for hosting an event they deemed un-Islamic prompted a veto from Khamenei last month.

Ahmadinejad veered close to defying the supreme leader by delaying a week before obeying his order and then naming the same man, Esfendiar Rahim-Mashaie, as his chief of staff.
He also sacked his hardline intelligence minister, who had criticized his actions, while his culture minister resigned.

The power struggle can only hamper the leadership's ability to tackle the Islamic Republic's economic problems, as well as the row over the nuclear program, which Iran says is for energy, but which the West suspects is aimed at bomb-making.

Another potential source of friction with the United States arose on Saturday when Iran arrested three American hikers who an Iraqi Kurdish official said had strayed across the border.

Adding to tense relations with the West, Tehran has accused Western powers of fuelling post-election unrest, particularly the United States and Britain which deny the charges.

The enemies (the West) should not think that they can bring the Islamic republic to its knees by such small deeds, Khamenei said at the official ceremony, adding:

They should face up to the facts in Iran.

Ahmadinejad renewed his attack on the West, saying some Western countries had been selfish and meddlesome over the election and called on them to correct their brutal approach.

Then they might find a way to the Iranian nation's circle of friendship ... We would never tolerate dishonesty, selfishness and discourtesy, he said at the ceremony.

In an apparent effort to deter further street protests, Iran on Saturday put 100 protesters, including senior moderate figures, on trial. They face a range of charges, including acting against national security, which is punishable by death.

Rights groups say hundreds of people, including senior pro-reform politicians, journalists and lawyers, have been detained since the election. The mass trial has no precedent in revolutionary Iran's 30-year history and resumes on Thursday.

Leading reformers, including Khatami, have rejected what they say is a show trial and accused the government of extracting confessions from some defendants under duress, adding the trials violated the constitution.

Many of the defendants spent weeks in jail without access to lawyers, Mousavi said on Sunday. He said the trial was an awkward preparation for the start of Ahmadinejad's new term.

Even some hardliners have criticized the trial and the official portrayal of the protesters as people determined to overthrow Iran's system of government.

(Writing by Parisa Hafezi, Editing by Peter Millership)