President Obama cautiously criticized the Iranian government Tuesday for carrying out a deadly crackdown on street demonstrations, as hard-line legislators in Tehran called for the execution of several prominent opposition leaders.

Obama's careful formulation - calling on the government to allow protesters to express their grievances but stopping short of calling for a change in leadership - highlighted the sharp differences between the political dynamic that his administration faces in Iran and the one that shaped the recent revolt in Egypt.

In Egypt, Obama had to balance the United States' long-standing support for a secular ally against the reality that popular backing for President Hosni Mubarak had all but evaporated. But in Iran, Obama confronts an Islamist regime hostile to U.S. interests and eager to turn any opposition movement into a proxy for the United States and Israel.

Earlier in the day, scores of Iranian lawmakers led a demonstration on the floor of parliament, calling for the execution of Mir Hossein Mousavi and Mehdi Karroubi, who have been under house arrest for some time. In a statement, 221 members of parliament said: "We believe the people have lost their patience and demand capital punishment."

The threat provided an ominous turn to the Iranian unrest, which Obama had yet to comment on publicly until his Tuesday news conference.

In the days before the Egyptian turmoil reached its climax, Obama aligned himself with the demonstrators' demand for a new government. With Iran, he has not been so bold.

His call for Iran's government to allow peaceful protest echoed the one he made after the opposition Green Movement emerged on Tehran's streets in June 2009 following a disputed presidential election, a response many conservatives criticized as tepid.

"We were clear then and we are clear now that what has been true in Egypt should be true in Iran, which is that people should be able to express their opinions and their grievances and seek a more responsive government," Obama said. "What's been different is the Iranian government's response, which is to shoot people and beat people and arrest people."

Obama spoke as anti-government demonstrations spread in the region, driven by what he described as "a young, vibrant generation within the Middle East that is looking for greater opportunity."

In a message that he addressed to "friend and foe alike," Obama said, "If you are governing these countries, you've got to get ahead of change," a tacit warning to such U.S. allies as Saudi Arabia, Jordan and others with autocratic rulers contending with rising democracy movements.

The State Department recently began Farsi and Arabic-language Twitter feeds to better reach those young demonstrators, sending out key statements from the president and administration officials. The Arabic feed, launched Feb. 9, has more than 1,200 followers; the Farsi feed, which began four days later, has nearly 3,500.

"What has become clear during Egypt and Tunisia is that you need to communicate in the space where people are talking," said Tommy Vietor, the National Security Council spokesman.

Obama did not comment directly on the execution threat, made by fist-pumping lawmakers a day after anti-government demonstrators defied an official ban on protests.

But he said he found it "ironic" that Iran's government is "pretending to celebrate what happened in Egypt when, in fact, they have acted in direct contrast to what happened in Egypt by gunning down and beating people who were trying to express themselves peacefully."

The mood on Tehran's streets has changed dramatically since Monday's demonstration, when two people were killed, according to the semiofficial Fars News Agency.

Although opposition Web sites have said the victims were protesters, government-backed entities assert that the men were members of a paramilitary organization and had been killed by the opposition.

Kazem Jalali, a member of the National Security and Foreign Policy Commission of the parliament, told Fars that "the efforts of the supreme leader [Ayatollah Ali Khamenei] were focused on trying to bring Mousavi and Karroubi back into the folds of the revolution."

"But these persons have purged themselves from the system," he said. "The parliament demands the strongest punishment for Mousavi and Karroubi."

In his news conference, Obama continued to focus on the demonstrations underway and not on his preferred outcome, a tactic he adopted during the 18-day uprising in Egypt.

Obama had more leverage in Egypt, where Mubarak had enjoyed American support and billions in U.S. aid since emerging from the military three decades ago to lead the country after his predecessor, Anwar Sadat, was assassinated. There was no such support or funding in Iran, where the 1979 revolution toppled the U.S.-backed shah and ushered in an Islamist government hostile to most American interests.

White House officials say Obama's caution stems from the same concern that guided his response in June 2009: that a clear U.S. call for regime change in Iran would allow President Mahmoud Ahmadinejad to cast the protest movement as a creation of Western governments and Israel.

Obama pointed to the lack of anti-U.S. sentiment in Tahrir Square during Egypt's uprising as evidence that allowing demonstrators to take the lead - without instructions or goals announced from Washington - was the correct course to take.

On Tuesday, Ahmad Khatami, an influential Friday prayer leader appointed by Khamenei, said the opposition leaders were guilty of "moharebeh," a legal term in Shiite Islam that means "waging war against God." The crime carries the death penalty in Iran.

In theory, Iran's judiciary would decide whether to press the case, but the issue is likely to fall to Khamenei, who decides all important matters of state.

During the past year, he effectively prevented the arrests of Karroubi and Mousavi by offering them a path to redemption if they admitted their mistakes and endorsed Iran's Islamist system.

Their arrests would escalate tensions on Tehran's streets, where there have been no new protests since Monday's crackdown.

Speaking live on state television, Ahmadinejad said anti-government demonstrators and their leaders planned to tarnish the "brilliance" of the Iranian nation.

"The Iranian nation is a shining sun," Ahmadinejad said. "They threw some dust toward the sun. . . . They should know that the dust will certainly return into their own eyes."

Erdbrink reported from Tehran. Special correspondent Kay Armin Serjoie contributed to this report.