The outpouring in Azadi, or Freedom, Square for reformist leader Mir Hossein Mousavi followed a decision by Iran's most powerful figure for an investigation into the vote-rigging allegations.
Security forces watched quietly, with shields and batons at their sides.
Later, a group of demonstrators with fuel canisters set a small fire at a compound of a volunteer militia linked to Iran's Revolutionary Guard as the crowd dispersed from the square. As some tried to storm the building, people on the roof could be seen firing at the demonstrators at the northern edge of the square, away from the heart of the rally.
The chanting demonstrators had defied an Interior Ministry ban and streamed into central Tehran -- an outpouring for Mousavi that swelled as more poured from buildings and side streets.
The crowd -- many wearing the trademark green color of Mousavi's campaign -- was more than five miles long.
"I am ready to pay any price to materialize the ideals of you dear people," Mousavi said, speaking though a portable loudspeaker. "People feel their wisdom has been insulted. We have to pursue legal channels to regain our trampled rights and stop this last lie, and stand up to fraud and this astonishing charade."
Mousavi said his solution was "canceling the result of this disputed election."
International polling experts and Iran analysts said the speed of the vote count, in which almost 40 million handwritten paper ballots appear to have been counted in a matter of hours, coupled with a lack of detailed election data normally released by officials, was fueling suspicion around Ahmadinejad's landslide victory.
Mousavi's newspaper, Kalemeh Sabz, or the Green Word, reported on its website that more than 10 million votes were missing national identification numbers similar to U.S. Social Security numbers, which make the votes "untraceable." It did not say how it knew that information.
Mousavi said some polling stations closed early with voters still in line, and he charged that representatives of his campaign were expelled from polling centers even though each candidate was allowed one observer at each location. He has not provided evidence to support the accusations.
His supporters have also reported intimidation by security forces who maintained a strong presence around polling stations.
Mousavi said the results also may have been affected by a shortage of ballot papers in the provinces of Fars and East Azerbaijan, where he had been expected to do well because he is among the country's Azeri minority. He said the shortage was despite the fact that officials had 17 million extra ballots ready.
Interior Ministry results show that Ahmadinejad won in East Azerbaijan.
"This will have the least cost for our nation. Otherwise, nothing will remain of people's trust in the government and ruling system."
The crowd roared back: "Long live Mousavi."
One placard said, in English: "This is not election. This is selection." Other marchers held signs proclaiming "We want our vote!" and they raised their fingers in a V-for-victory salute.
"We want our president, not the one who was forced on us," said 28-year-old Sara, who gave only her first name because she feared reprisal from authorities.
As darkness fell, cries of "Allahu akbar!" -- "God is great!" -- were heard across central Tehran as people gathered on rooftops for a second straight night. On Sunday night, Ahmadinejad opponents shouted "Death to the dictator!" The protest bore deep historic resonance -- it was how the leader of the Islamic Revolution Ayatollah Ruhollah Khomeini asked Iran to unite against the Western-backed shah 30 years earlier.
Elsewhere in Iran, witnesses saw hundreds of Mousavi supporters gathered in the heart of the central city of Esfahan. Some broke windows of police stations and buildings belonging to the government's Revolutionary Courts, tribunals designated for crimes against the principles of the Islamic ruling system.
Thousands gathered at a university in the northeastern city of Mashhad, witnesses told the AP by phone. In other parts of the town, generally seen as more conservative than Tehran, there were scattered gatherings, and police with batons beat demonstrators.
Police in the southern city of Shiraz fired in the air to disperse several pro-Mousavi gatherings. Police Gen. Ali Moayeri of the Fars Province police told reporters that officers had been "authorized to shoot. From now on we will respond harshly."
One of Mousavi's Web sites said a student protester was killed early Monday in clashes with plainclothes hard-liners in Shiraz.
In the heavily Arab city of Ahvaz near the Iraqi border, about 2,000 people chanted, "We don't want a dictator!" Police attacked some of them with batons.
Most media are not allowed to travel beyond Tehran and thus cannot independently confirm protests elsewhere.
Earlier Monday, Supreme Leader Ayatollah Ali Khamenei directed one of Iran's most influential bodies, the Guardian Council, to examine the election claims. But the move by Khamenei -- who had earlier welcomed the election results -- had no guarantee it would satisfy those challenging Ahmadinejad's re-election or quell days of rioting after Friday's election that left parts of Tehran scarred by flames and shattered store fronts.
The 12-member Guardian Council, made up of clerics and experts in Islamic law and closely allied to Khamenei, must certify ballot results and has the apparent authority to nullify an election. But it would be an unprecedented step. Claims of voting irregularities went to the council after Ahmadinejad's upset victory in 2005, but there was no official word on the outcome of the inquiry, and the vote stood.
More likely, the dramatic intervention by Khamenei could buy time in hopes of reducing the anti-Ahmadinejad anger. The prospect of spiraling protests and clashes is the ultimate nightmare for the Islamic establishment, which could be forced into back-and-forth confrontations and risks having the dissidents move past the elected officials and directly target the ruling theocracy.
Government shootings of protesters before the Islamic Revolution set up a cycle of violence in which the shah's forces opened fire on demonstrators massing to mourn "martyrs" at the end of the 40-day Muslim mourning period. Forty days later, demonstrators gathered again, there were new shootings, and the cycle continued.
Monday's massive display of opposition unity suggested a possible shift in tactics by authorities after cracking down hard on days of rioting. Although rallies were outlawed earlier, security forces were not ordered to move against the protesters.
State TV quoted Khamenei as ordering the Guardian Council to "carefully probe" the allegations of fraud, which were contained in a letter Mousavi submitted Sunday.
On Saturday, however, Khamenei urged the nation to unite behind Ahmadinejad and called the result a "divine assessment."
The results touched off three days of the worst unrest in Tehran in a decade. Protesters set fires and battled riot police, including a clash overnight at Tehran University after about 3,000 students gathered to oppose the election results.
Security forces have struck back with targeted arrests of pro-reform activists and by blocking text messaging and pro-Mousavi Web sites used to rally his supporters.
The unrest risked bringing splits among Iran's clerical elite, including some influential Shiite scholars raising concern about possible election irregularities and at least one member of the ruling theocracy, former president Hashemi Rafsanjani, openly critical of Ahmadinejad in the campaign.
According to a pro-Mousavi Web site, he sent a letter to senior clerics in Qom, Iran's main center of Islamic learning, to spell out his claims.
The accusations also have brought growing international concern. On Sunday, Vice President Joe Biden raised questions about whether the vote reflected the wishes of the Iranian people.
Britain and Germany joined the calls of alarm over the confrontations. In Paris, the Foreign Ministry summoned the Iranian ambassador to discuss the allegations of vote tampering and the violence.
Overnight, police and hard-line militia stormed Tehran University, ransacking dormitories and arresting dozens of students. The university was the site of serious clashes against student-led protests in 1999 and is one of the nerve centers of the pro-reform movement.
The gathering at the university started with students chanting "Death to the dictator." But it quickly erupted into clashes as students threw rocks and Molotov cocktails at police, who fired tear gas and plastic bullets, a 25-year-old student who witnessed the fighting told the AP. He would only give one name, Akbar, out of fear for his safety.
The students set vehicles afire and hurled stones and bricks at the police, he said. Hard-line militia volunteers loyal to the Revolutionary Guard stormed the dormitories, ransacking student rooms and smashing computers and furniture, Akbar said.
Before leaving around 4 a.m., the police took memory cards and computer software material, Akbar said, adding that dozens of students were arrested.
He said many students suffered bruises, cuts and broken bones in the scuffles.
"Many students are now leaving to go home to their families, they are scared," he said. "But others are staying. The police and militia say they will be back and arrest any students they see."
"I want to stay because they beat us and we won't retreat," he added.
In Moscow, the Iranian Embassy said Ahmadinejad postponed his visit to Russia until Tuesday. Ahmadinejad had been expected to travel to the Russian city of Yekaterinburg and meet on Monday with President Dmitry Medvedev on the sidelines of a regional summit.