TEHRAN - Iranian President Mahmoud Ahmadinejad, speaking several hours before Egyptian President Hosni Mubarak stepped down, urged Egyptians to continue their protests and to "free" themselves and choose their own leaders and their own form of government.

In a speech Friday during a large state-sponsored rally to celebrate the 32nd anniversary of Iran's Islamic revolution, Ahmadinejad said that the uprisings in the Arab world have been inspired by his country's struggle against Western powers.

The protests, he said, herald the emergence of a new Middle East where, despite "satanic" Western designs, the United States and Israel would not be able to interfere. "The arrogant powers will have no place in this Middle East," Ahmadinejad said.

Government representatives and soldiers handed out Egyptian flags to teenage schoolgirls, who sang Iran's praise, calling it the "cradle of Islamic belief and love."

The crisis that has been roiling Egypt, a key U.S. ally in the region, dominated Friday's celebration. Ahmadinejad said that the 12th imam Mahdi, a revered 9th-century Shiite saint, had directed the uprisings in Egypt and Tunisia.

"This is a global revolution, managed by the imam of the ages," he told the crowds gathered in and around Tehran's central Azadi Square.

He predicted the formation of a world government, ruled by the 12th imam: "Hearts and beliefs are swiftly leaning toward forming a global governance and the necessity of the rule of the perfect human, linked to the heavens."

Days before Friday's rally, opposition leaders and former presidential challengers Mir Hossein Mousavi and Mehdi Karroubi requested permission to stage a protest Monday in solidarity with the people of Egypt and Tunisia. It is unlikely that permission will be given, but opposition Web sites say that protests might be held anyway.

Government officials have accused the activists of wanting to use the rally to protest domestic issues.