The protest – in defiance of warnings of draconian retribution by the authorities – was a potent declaration that the opposition is alive and kicking despite a ferocious crackdown since June's "stolen" presidential elections.
As violent clashes between opposition and regime supporters gripped Tehran, Ahmadinejad invited international condemnation before his appearance at the UN General Assembly in New York next week by branding the Holocaust "a lie".
The Iranian president has dismissed the Holocaust as a "myth" before, but this time he was more explicit than ever. "The pretext (Holocaust) for the creation of the Zionist regime (Israel) is false," he said in a Friday prayers sermon at Tehran University. "It is a lie based on an unprovable and mythical claim. Confronting the Zionist regime is a national and religious duty," Ahmadinejad thundered as his audience replied in well-drilled unison with cries of "Death to Israel, Death to the United States."
As he spoke, demonstrators nearby chanted, "Down with Ahmadinejad" and "Torture and rape are not effective any more". They shouted in support of Mir-Hossein Mousavi, who millions of Iranians believe was the true winner of June's elections.
The protesters, some throwing stones, were confronted by baton-wielding riot police who beat them and fired tear gas to disperse the crowds.
Mousavi was forced to flee the rally after an angry hardline mob attacked his car. The former reformist president and cleric, Mohammad Khatami, was assaulted by regime hardliners and knocked to the ground before he was rescued by riot police. Mehdi Karrubi, another prominent reformist leader who contested June's presidential elections, also had to flee.
Meanwhile, Ahmadinejad was warning leaders of Western-backed Arab and Muslim countries about dealing with Israel. "This regime will not last long. Do not tie your fate to it," he proclaimed.
David Milliband, Britain's foreign secretary, condemned his tirade as "abhorrent as well as ignorant".
Moderates in Tehran are likely to be appalled by Ahmadinejad's latest provocative outburst. Iranian officials are due to meet on 1 October with six world powers, including the United States, to determine whether the Iranian nuclear crisis can be defused.
Iran's Revolutionary Guards and the country's supreme leader, Ayatollah Ali Khamenei, had warned of a crackdown if the opposition attempted to take advantage of yesterday's pro-Palestinian ceremony, established 30 years ago by Ayatollah Khomeini, the late founder of the Islamic Revolution, to showcase Iran's anti-Israeli stance and its support of the Palestinians.
Every year, the Iranian government encourages a huge turn-out on the streets to mark the occasion. Yesterday, however, the opposition used it to vent their fury against the government, which has banned all post-election protests.
The opposition's thinking was inventive. Green is the colour of Mousavi's anti-Ahmadinejad movement and was sported by demonstrators – but it is also the colour of the radical Palestinian movement, Hamas, which the Iranian government supports.
Protesters chanted: "Not Gaza, not Lebanon – our life is for Iran" – defying the regime's support for the Palestinian militants in Gaza and Lebanon's Hezbollah guerrilla movement. At least ten protesters were hauled away by plainclothes security agents. The regime had done its utmost to prevent the opposition turning the Jerusalem Day rally to its advantage. Apart from dire warnings against ordinary Iranians, it banned the highly influential former president Akbar Hashemi Rafsanjani from delivering Friday prayers as he has done for the past 25 years.
Instead, he joined protestors at the rally.