TEHRAN (Reuters) - Thousands of protesters clashed with police after President Mahmoud Ahmadinejad won an election which his reformist challenger called a “dangerous charade.”

The protests were a rare direct challenge to Iranian authorities. The result and its violent aftermath raised fresh questions about the direction of Iranian policies at a time when U.S. President Barack Obama wants to improve relations with Iran.

Supreme Leader Ayatollah Ali Khamenei told Iranians to respect Ahmadinejad’s victory, which upset expectations that reformist candidate Mirhossein Mousavi might win the race.

Interior Minister Sadeq Mahsouli, an Ahmadinejad ally, declared the president had been re-elected with 62.6 percent of the vote, against 33.7 percent for Mousavi.

Mousavi complained of violations and vote-rigging -- 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.

After the result was announced, thousands of his supporters took to the streets, some chanting, “What happened to our vote?.” Others shouted anti-Ahmadinejad slogans. “We are Iranians too,” and “Mousavi is our president,” they shouted.

Police beat protesters with batons as they spread out across the capital. Small fires burned at roadsides.

Though the protests were small compared to the mass demonstrations that led to the 1979 Islamic 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.”

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.

Slideshow ( 23 images )

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.

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.

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.