It’s not clear what Mr. Moussavi thinks about democracy, but it’s a good bet that he’s willing to entrust the people with more power than was Mr. Khatami, who despite some differences could neither really break with his ruling clerical brethren, nor free himself from the age-old Islamic belief that the faithful need clerical supervision. And even if Mr. Moussavi isn’t the ideal reformer  he was prime minister in the 1980s  he is surrounded by the best and brightest of Iran. The regime has lost almost all the country’s intellectual capital. Even among the clergy, the best minds  the ones faithful Iranians talk about, like Grand Ayatollah Hossein Ali Montazeri  have distanced themselves from Ayatollah Khamenei. I can’t think of a serious book written by an Iranian since the fall of Mr. Khatami expounding the Islamic Republic as a model for Muslims.

The reverse parallels here with the rest of the Islamic Middle East are striking. Where secular dictatorships rule, the best and the brightest are often attracted to the Islamist cause. The moral repugnance of these regimes trumps the appeal of their Westernization. Muslim fundamentalists often espouse democracy either because it is the only peaceful means of dethroning their rulers or because they really do believe that most Muslims are “good” Muslims. Democracy would make their societies more virtuous, they feel, more likely to preach and practice the traditional injunction to command good and forbid evil.

Until now, the Islamic Republic has had a propaganda heyday among devout Arabs, depicting itself as a virtuous state with a workable level of democracy  just enough to give the regime legitimacy and stability. Ali Larijani, the speaker of Iran’s Parliament and the wicked genius behind the crushing of the reform movement during Mr. Khatami’s presidency, loves to emphasize Iran’s democracy when he travels abroad, always highlighting America’s preference for secular dictatorships.

Now the clerical regime can no longer make this argument. As Iranians have come to know theocracy intimately, secularism has become increasingly attractive. Iran now produces brilliant clerics who argue in favor of the separation of church and state as a means of saving the faith from corrupting power.

Indeed, Iranians are on the threshold of turning the Koran’s ethical injunction into a democratic commandment: nothing good can be commanded without a vote of the people. The democracy-supporting clerics of Iraq are trying to do the same thing, but the Iranians, much further advanced in their thinking about church and state, will surely be much bolder. Whether he intended it or not, Mr. Moussavi  and indirectly Ayatollah Khamenei because of his crude determination to keep the former prime minister from power  has probably begun the final countdown on the Islamic Republic.

We can only guess about the effect of an Iranian crack-up on the rest of the Middle East. Although the region’s Sunni rulers were spooked by the aggressiveness of Mr. Ahmadinejad and Ayatollah Khamenei (not to mention the idea of a Shiite state with nuclear weapons), the birth of real democracy in Iran, always the most dynamic state in the region, cannot but cause acute anxiety. Sunni Arab fundamentalists, whose day has not yet arrived, will be fascinating to watch. They will surely see the awesome power of democracy; they will probably conclude, however reluctantly, that God cannot be the sole legislator of the laws and ethics that good Muslims want to live by.

And American policy? For starters, many of America’s supposed allies may welcome a Khamenei crackdown. This may complicate matters for President Obama. But he should take note: inside Iran, the nuclear issue isn’t what the people are fighting about. They are fighting for freedom. Even if Ayatollah Khamenei proves triumphant in this round, the president should get on the right side of history. He has nothing to lose: the supreme leader is never going to give ground on the nuclear issue. And as the clerical regime gets nastier at home, it will become nastier abroad. Mir Hussein Moussavi is Mr. Obama’s only hope.