They were joined by the civil servants, police officers and pensioners who all enjoyed the incumbent’s oil-financed generosity to his base, by those who relished his name-naming attack on corruption and by those who took pride in his defiance of the West.

Outside Iran, the result was comforting to hawks in Israel and some Western capitals who had feared that a more congenial Iranian president would cause the world to let down its guard against a country galloping toward nuclear weapons capability. (Mr. Moussavi, while promising a more conciliatory foreign policy, did not disavow the country’s nuclear-processing project, which Iran insists is for civilian ends alone.)

“In fact, Moussavi will be more difficult to deal with, because he will be nicer,” one skeptical Western diplomat said on the eve of the vote.

Among downcast Iranian journalists and academics, the chatter focused on why the interlocking leadership of clerics, military officers and politicians, without whose acquiescence little of importance happens, decided to stick with Mr. Ahmadinejad. Did they panic at the unexpected passion for change that arose in the closing weeks of the Moussavi campaign? Did Mr. Moussavi go too far in his promises of women’s rights, civil freedom and a more conciliatory approach to the West? Or was the surge an illusion after all, the product of wishful thinking?

The optimists in Iran and abroad have to ask themselves whether the joyful ruckus that filled the streets represented a new popular force or just an opportunity to let off steam. While Iran is not quite the closed society many imagine  it is a nation of text messagers and Facebook users, with access to Persian-language BBC broadcasts and other independent voices  it is still a controlled society.

On the street, the speculation focused more on how the election was manipulated, as many voters insisted it must have been for Mr. Ahmadinejad to score such a preposterous margin of victory.