Iran's Supreme Leader Ayatollah Ali Khamenei appealed for calm on Friday and attacked enemies questioning the result of a presidential vote that has sparked the biggest street protests in the Islamic Republic's history.

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

Today the Iranian nation needs calm, Khamenei said in his first address to the nation since the upheaval began.

He said Iran's enemies were targeting the legitimacy of the Islamic establishment by disputing the outcome of the election.

Tens of thousands of Iranians had gathered in and around Tehran University to hear Khamenei's Friday prayer sermon.

The Supreme Leader, Iran's ultimate authority, had earlier urged his compatriots to unite behind hardline President Mahmoud Ahmadinejad, the declared winner of last Friday's poll.

But supporters of the runner-up, Mirhossein Mousavi, have so far ignored the call, holding huge unauthorized rallies.

People chanting slogans and holding posters of Khamenei, Ahmadinejad and Ayatollah Ruhollah Khomenei, the father of the 1979 Islamic revolution, packed streets outside the university.

At least one police helicopter hovered overhead.

Ahmadinejad has been our president for four years, and during this time he has always told the truth to our people, said Javid Abbasirad, 48, outside the university gates.

At the same venue, hundreds of university students had demonstrated in support of Mousavi on Sunday, hurling stones at riot police trying to disperse protesters outside the gates.

ANTI-WESTERN SLOGANS

Some in the crowd for Friday prayers were draped in Iranian flags. Others held placards with anti-Western slogans.

Don't let the history of Iran be written with the pen of foreigners, one flyer said, reflecting official Iranian anger at international criticism of the post-election violence.

U.S. President Barack Obama's administration has muted its comments to keep the door ajar for possible dialogue.

A group of clerics and citizens left the holy city of Qom for a 150 km (100 mile) walk to Tehran in a show of support for Khamenei, state radio and television reported.

Khamenei's speech followed six days of protests by Mousavi supporters. On Thursday, tens of thousands of black-clad marchers bore candles to mourn those killed in earlier rallies.

The protests are the largest and most widespread since the revolution in Iran, the world's fifth biggest oil exporter, which is also at odds with the West over its nuclear program.

Iranian state media has reported seven or eight people killed in protests since the election results were published on June 13. Scores of reformists have been arrested and authorities have cracked down on both foreign and domestic media.

(Additional reporting by Dominic Evans and Hossein Jaseb in Tehran; Editing by Alistair Lyon and Charles Dick)