WASHINGTON — During his decades in Iranian politics, Ali Akbar Hashemi Rafsanjani has been praised as a pragmatist, criticized as spineless, accused of corruption and dismissed as a has-been.

Now, in assailing the government’s handling of last month’s disputed presidential election, Mr. Rafsanjani, a 75-year-old cleric and former president, has cast himself in a new light: as a player with the authority to interpret the ideals of Iran’s 30-year-old Islamic republic.

Using his perch as a designated prayer leader on Friday to deliver the speech of a lifetime, Mr. Rafsanjani abandoned his customary caution to demand that the government release those arrested in recent weeks, ease restrictions on the media and eradicate the “doubt” the Iranian people have about the election result. And he implicitly challenged the authority of the country’s supreme leader, Ayatollah Ali Khamenei, to make decisions without seeking consensus.

Behind the words was the assertion that for the Islamic republic to survive, it must restore its legitimacy, reaffirm its republican institutions and find a formula for governing.

To establish his own legitimacy, Mr. Rafsanjani evoked his long political history.

“What you are hearing now is from a person who has been with the revolution second by second from the very beginning of the struggle,” he said, adding, “We are talking about 60 years ago up until today.”

He recalled that his mentor, Ayatollah Ruhollah Khomeini, the father of the 1979 revolution, said that the “people’s will” must be done, and in this case, he said, the trust of the people had been broken.

Mr. Rafsanjani was a supporter of the opposition candidate, Mir Hussein Moussavi, during the campaign, and by speaking out on Friday he seemed to be moving closer to Mr. Moussavi as a public symbol of opposition. But Mr. Rafsanjani also took care not to directly dispute the government’s declaration that President Mahmoud Ahmadinejad had won the election.

In delivering his sermon, Mr. Rafsanjani was defying a government campaign to silence him, in which senior officials have interspersed personal attacks with veiled threats. That campaign continued Saturday, when conservative figures criticized his speech.

He was also essentially usurping the institutional role of Ayatollah Khamenei.

“This was a speech Khamenei should have given,” said Farideh Farhi, a political scientist at the University of Hawaii. “That’s his designated role as the spiritual and political guide, to be above the fray. But Khamenei is probably too insecure and has too much to lose. He took sides. Rafsanjani rose to the occasion.”

Still, it would be wrong to say that Mr. Rafsanjani has suddenly become a proponent of justice, human rights and freedom.

In the summer of 1999, after all, when the government crushed student demonstrations at Tehran University, he delivered a harsh sermon in the same place as he did on Friday. Back then, he blamed “enemies of the revolution” and “sources outside the country” for the unrest. He praised the use of force by the state.

During much of his earlier eight-year presidency, many Iranians were executed, including political dissidents, drug offenders, Communists, Kurds, Bahais, even clerics.

Politically, Mr. Rafsanjani was humiliated twice: in 2000 when he ran for Parliament and came in 30th and last place in Tehran (amid charges of ballot fraud in his favor), and again in 2005, when he performed dismally in his bid to regain the presidency.

But unlike many political figures, and certainly unlike most clerics, Mr. Rafsanjani is the consummate politician. He refuses to abandon the political battlefield in a country in which silence in the face of defeat is the norm.

He also knows how to shift gears. A campaign photograph in the 2000 campaign showed him without his turban. He must have thought that a clerical uniform had become a liability.

Mr. Rafsanjani’s bold public stance is not without risks. Members of his family have been briefly detained during this period of turmoil, and the government could use his record, and his family’s financial dealings, to discredit him.

For his part, Ayatollah Khamenei delivered his own notable sermon four weeks ago, in which he embraced the victory of Mr. Ahmadinejad, called the election proof of the people’s trust in the system and threatened more violence if demonstrations continued.

Mr. Rafsanjani struggled to woo the center; the ayatollah stuck to his base of support on the right.

Mr. Rafsanjani spoke about the Prophet Muhammad’s style of governing in Medina, with its emphasis on listening to the people, and treating them with respect and “Islamic kindness.”

He used a pragmatic argument in calling for the release of those who have been arrested.

“Let’s not allow our enemies to reprimand and laugh at us and hatch plots against us just because a few certain people are in prison,” Mr. Rafsanjani said.

Ayatollah Khamenei, by contrast, in his sermon railed about the enemies of the prophet and the foreign enemies both inside and outside Iran. “The violators,” as he called them, are “the ill-wishers, mercenaries and agents of the Western intelligence services and the Zionists.”

Ironically, his speech sounded much like the one Mr. Rafsanjani gave after the disturbances a decade ago.

From the early days of the revolution, Mr. Rafsanjani has favored pragmatism over religious absolutism.

After the seizure of the American Embassy in Tehran in 1979, Iran’s leaders demanded the return of the exiled Shah Mohammed Reza Pahlavi as a condition of the release of the 52 American hostages. Mr. Rafsanjani had a better idea: “If the shah dies, that would help,” he said to this reporter in an interview in 1980. (Shortly afterward, the shah died of complications caused by cancer.)

In 1986, after the Reagan administration’s secret American arms sales to Iran were disclosed, Mr. Rafsanjani, then the speaker of Parliament, used his Friday sermon to explain why. He said Iran needed to acquire weapons to fight Iraq, even if it meant dealing with the enemy, the United States. Later, he was credited with helping to persuade Ayatollah Khomeini to end the eight-year war.

A state-builder, Mr. Rafsanjani even set aside religion to rehabilitate the image of Persepolis, the site of the 2,500-year-old Persian empire, saying, “Our people must know that they are not without a history.”

This time, he did not lay out goals. He did not say whether he hoped to get the election results overturned or merely to convince the country to make peace with those results.

“He doesn’t address the basic problem for the opposition: that they have been dealt with brutally on the streets and that this was a manipulated election,” said Shaul Bakhash, professor of Middle Eastern history at George Mason University.

In his 1963 book about miracles, Mr. Rafsanjani bragged that he was saved from an assassin’s bullet because of his “revolutionary speed” and his willingness to “punch those who say nonsense.”

Given the fluid nature of Iranian politics, it would be foolish to predict whether he can make miracles today.