Thousands of people clashed with police on Saturday after the disputed election victory of President Mahmoud Ahmadinejad sparked the biggest protests in Tehran since the 1979 Islamic revolution.

Supreme Leader Ayatollah Ali Khamenei told Iranians to respect Ahmadinejad's victory in a presidential election that his closest challenger described as a dangerous charade.

Ahmadinejad's triumph in Friday's vote upset expectations that reformist candidate Mirhossein Mousavi might win the race.

Thousands of Mousavi supporters took part in the protests, some chanting, What happened to our vote?. Others chanted anti-Ahmadinejad slogans, bringing traffic to a standstill. We are Iranians too, and Mousavi is our president, they shouted.

Interior Minister Sadeq Mahsouli, an Ahmadinejad ally, declared the president had been re-elected to a second four-year term with 62.6 percent of the vote, against 33.7 percent for Mousavi, in a record 85 percent turnout.

Mousavi protested against what he called violations and vote-rigging during the election -- allegations rejected by Interior Ministry officials.

I'm warning I will not surrender to this dangerous charade. The result of such performance by some officials will jeopardize the pillars of the Islamic Republic and will establish tyranny, Mousavi said in a statement made available to Reuters.

In a rare challenge to the authorities, thousands of his supporters defied police warnings that they would confront anyone holding unauthorized protests. Police beat protesters with batons as they spread out across the capital.

In one incident, police on motorcycles beat Mousavi backers who were staging a sit-in protest at the capital's Vanak square.

Mousavi said members of his election headquarters had been beaten with batons, wooden sticks and electrical rods.

At Tehran University, some 100 police with helmets and shields used tear and pepper gas as they chased 300-400 students. Small fires were burning on the street.

Though the protests were small compared to the mass demonstrations that led to the 1979 revolution, they were the most widespread in the city since then.

Khamenei, Iran's top authority, told defeated candidates and their supporters to avoid provocative behavior.

The chosen and respected president is the president of all the Iranian nation and everyone, including yesterday's competitors, must unanimously support and help him, Khamenei said in a statement read on state television.

Ahmadinejad, in a televised address to the nation, said the election had been free and healthy. He said people voted for my policies.

NUCLEAR DISPUTE

Iranian and Western analysts said Ahmadinejad's re-election would disappoint Western powers aiming to convince Iran to halt a nuclear program they suspect is aimed at making bombs, and could further complicate efforts by U.S. President Barack Obama to reach out to Tehran.

It doesn't augur well for an early and peaceful settlement of the nuclear dispute, said Mark Fitzpatrick at London's International Institute for Strategic Studies.

U.S. Secretary of State Hillary Clinton said the United States was monitoring the outcome of the election closely and hoped the result reflected the will of the Iranian people.

A bitter campaign generated intense excitement inside Iran and revealed deep divisions between those backing Ahmadinejad and those pushing for social and political change.

Ahmadinejad accused his rivals of undermining the Islamic Republic by advocating detente with the West. Mousavi said the president's extremist foreign policy had humiliated Iranians.

On Friday night, before official results emerged, Mousavi had claimed to be the definite winner. He said many people had been unable to vote and ballot papers were lacking.

He also accused authorities of blocking text messaging, with which his campaign tried to reach young, urban voters.

On Saturday, Iran's students' news agency ISNA quoted Tehran's Deputy Prosecutor General Mahmoud Salarkia as saying 10 people had been detained for agitating public opinion through websites and blogs by propagating untruthful reports.

Ahmadinejad draws most of his support from rural areas and poorer big city neighborhoods. Mousavi enjoys strong backing in wealthier urban centers, especially among women and the young.

Two other candidates attracted only minimal support.

Analysts expressed disbelief over the election result.

I'm surprised at the regime's audacity in declaring such a large margin for Ahmadinejad, given that in the run-up, the momentum seemed to be in the other direction, said Fitzpatrick.

The election results are incredible, said Ali Ansari at the Institute for Iranian Studies at St. Andrews University in Scotland. If it was a genuine election landslide, surely people should be out on the streets in euphoria...

Ahmadinejad, 52, won power four years ago, vowing to revive the values of the Islamic revolution. He has expanded the nuclear program, which Iran says is only for electricity generation, and stirred international outrage by denying the Holocaust and calling for Israel to be wiped off the map.

(Additional reporting by Hossein Jaseb, Hashem Kalantari, Zahra Hosseinian in Tehran and Alistair Lyon in Beirut; Writing by Dominic Evans and Fredrik Dahl; Editing by Myra MacDonald)