The election commission said early Saturday morning that, with 77 percent of the votes counted, Mr. Ahmadinejad had won 65 percent and Mr. Moussavi had 32 percent, Reuters reported. Then at 8 a.m. Saturday, Iranian state media reported that Mr. Ahmadinejad had about 18 million votes and that Mr. Moussavi had 9 million. The other two candidates, Mehdi Karroubi and Mohsen Rezai, each won about 250,000 votes, the state media reported.

The election commission is part of the Interior Ministry, which Mr. Ahmadinejad controls. Some lawmakers were already congratulating Mr. Ahmadinejad, and some of his supporters were celebrating in the streets, the news agency said.

Some analysts warned that Mr. Moussavi’s supporters might take to the streets to protest on Saturday, despite a firm warning against any demonstrations by the deputy commander of the Iranian national police, Ahmadreza Radan. Early on Saturday morning the Tehran police began a “maneuver” to maintain security, the news agency said.

The emotional campaign was widely seen as a referendum on Mr. Ahmadinejad’s divisive policies. It pitted Mr. Moussavi, a former prime minister who has pledged to move Iran away from confrontation with the West, combat economic stagnation and expand women’s rights, against Mr. Ahmadinejad’s economic populism, social conservatism, and hard-line foreign policy.

Many women, young people, intellectuals and members of the moderate clerical establishment backed Mr. Moussavi. Mr. Ahmadinejad drew passionate support from poor rural Iranians as well as conservatives.

At his news conference, Mr. Moussavi cited irregularities that included a shortage of ballots. He accused the government of shutting down Web sites, newspapers and text messaging services throughout the country, crippling the opposition’s ability to communicate during the voting.

Fraud has been a prominent concern for Mr. Moussavi’s campaign, with many of his allies warning that Mr. Ahmadinejad could use the levers of state — the military, the Revolutionary Guard, and the Basij militia — to cajole or intimidate voters, or even engage in outright fraud. In 2005, Mr. Karroubi, who is also a candidate in this election, accused the Basij of rigging the vote in Mr. Ahmadinejad’s favor.

Advertisement Continue reading the main story

At his news conference, Mr. Moussavi called on the country’s supreme leader, Ayatollah Ali Khamenei, to help the country reach a “favorable conclusion.”

Ayatollah Khamenei, who has final authority over affairs of state, appears to be the only figure who could mediate between the two camps in the event of an open confrontation over the legitimacy of the vote. But it is not clear how much he knows about the crisis, or what role he might play.

Mr. Khamenei met on Friday with Akbar Hashemi Rafsanjani, a cleric, former president and backer of Mr. Moussavi’s who had warned the supreme leader in an unusual open letter on Tuesday about the possibility of election fraud, according to a political analyst who spoke on condition of anonymity, citing the gravity of the situation.

While casting his ballot earlier in the day Friday, Ayatollah Khamenei had said that people were using texting to spread rumors, but it is unclear if that is why the services were shut down.

Amid the confusion overnight, a reformist Web site called Fararu said Mr. Moussavi was talking with the two other candidates, Mr. Karroubi and Mr. Rezai, to discuss the situation. Mr. Karroubi is a reformist cleric and Mr. Rezai is a conservative and the former commander of Iran’s Revolutionary Guards.

Newsletter Sign Up Continue reading the main story Please verify you're not a robot by clicking the box. Invalid email address. Please re-enter. You must select a newsletter to subscribe to. Sign Up You will receive emails containing news content , updates and promotions from The New York Times. You may opt-out at any time. You agree to receive occasional updates and special offers for The New York Times's products and services. Thank you for subscribing. An error has occurred. Please try again later. View all New York Times newsletters.

Tens of millions of Iranians crowded voting stations throughout the day, with long lines forming outside some polling stations well before they opened at 8 a.m.

Polls were originally due to close at 6 p.m., but voting was extended by four hours.

The strong showing appeared to be driven in part by a broad movement against Mr. Ahmadinejad that has spurred vast opposition rallies in Iran’s major cities over the past few weeks. Many reform-oriented voters stayed away from the polls in 2005, and now say they are determined not to repeat the mistake.

According to Iran’s election rules, if none of the candidates wins more than 50 percent of the vote, the top two finishers will compete in a runoff in a week. Most analysts had assumed that the election would go to a second round, but in recent days, the extraordinary public support for Mr. Moussavi had led to predictions that he could win the presidency in the first round on Friday.

Iran’s president is less powerful than Ayatollah Khamenei, who has final authority over affairs of state. But the president wields great power over domestic affairs, and Mr. Ahmadinejad has skillfully used the office as a bully pulpit both at home and abroad.

Advertisement Continue reading the main story

As voting began on Friday morning, journalists gathered to watch Ayatollah Khamenei cast his vote in a mosque near his home in southern Tehran. Just after 8 a.m., a set of brown curtains opened and the leader emerged, a gaunt 69-year-old with glasses and a long white beard, with a black turban on his head and a black clerical gown draped around him. The journalists, mostly Iranians, gasped and then chanted a religious blessing.

The supreme leader presented his identity papers to an official standing nearby, cast his ballots and then gave a brief speech in which he praised the vigor of the election campaign.

“I am hearing about a vast participation of people, and I hear there are even gatherings at night,” the ayatollah said. “This shows the people’s awareness.”

Ayatollah Khamenei’s position on the presidential elections has been a matter of intense speculation. He has not endorsed anyone, but offered a description of the ideal candidate that sounded very much like Mr. Ahmadinejad.

A number of voters seemed anxious about the possibility of vote-tampering.

“I put one name in, but maybe it will change when it comes out of the box,” said Adel Shoghi, 29, who works as a clerk at a car manufacturing company and voted at a mosque in southern Tehran.

Like some other supporters of Mr. Moussavi, Mr. Shoghi seemed uneasy about making his position too explicit in public. But he said he favored Mr. Moussavi because Iran needed more civic freedoms and because Mr. Ahmadinejad worsened Iran’s pariah status internationally, making life hard for Iranians who travel.

His brother Mansoor, 27, said he had just voted for Mr. Ahmadinejad.

“He is more with the people, and he has a plain way of living,” he said, echoing comments made by many of his supporters.

Half an hour later, Mr. Moussavi arrived at the mosque to cast his vote, surrounded by a thick, shouting crowd of aides and photographers.

Advertisement Continue reading the main story

“This is a golden opportunity for us,” he said, as photographers jostled for position and voters struggled to hear. “All this unity and solidarity is the achievement of the revolution and the Islamic republic,” he said.

He left soon after, with his admirers in the courtyard still chanting, “Hail to Muhammad, the perfume of honesty and sincerity is coming.”

Mr. Ahmadinejad voted at another mosque, in southeast Tehran.