Just before midnight on a Friday evening a week before Iran’s much-disputed June 12 election, the initial tremors of the earthquake that has shaken the country to its core were palpable deep in south Tehran, a gritty, working-class section of the city with a reputation for being a stronghold of President Mahmoud Ahmadinejad.

Past shuttered shops and empty, debris-strewn sidewalks, a late-night stream of cars, trucks and motorcycles, engines revving, horns honking, roared along the wide boulevard. From open car windows emerged shouts and cheers, raised fists and hands brandishing posters of opposition contender Mir-Hossein Moussavi’s bearded, smiling visage. In the traffic ahead of us, a ramshackle open-air panel truck transported at least two dozen Ahmadinejad supporters clad in T-shirts, jeering at their opponents. As I traveled north from sprawling Imam Khomeini Square up to Ferdowsi Square and on the miles-long Vali Asr Street, the scene was similar. In a country not known for street politics, the tableau was stunning. My Iranian companion, an older man with years of experience in his country’s affairs, smiled and shook his head. “This is something new,” he said.

Indeed. Just over a year ago, when I visited Tehran, Shiraz, Isfahan and Qom on the eve of the March 2008 parliamentary elections, I spoke to scores of Iranians who were glumly considering whether to drag themselves to the polls and vote for the least-bad candidate or, more likely, not bother to vote at all. In 2009 the contrast could not have been more stark. The city was electric. Into the wee hours tens of thousands campaigned in a citywide free-for-all. Every morning Tehran was abuzz with the latest election news. Men crowded around newsstands to read the headlines and to discuss the previous night’s candidate debate. Just inside the main gate to Tehran University, two days before the election, a middle-aged guard who had lost a leg in the war with Iraq in the 1980s marveled at the thousands of students marching past, flying green banners in support of Moussavi’s reformist movement. “Enghelab!” he said, nodding. “It’s a revolution!” It’s a word I’d hear over and over again, from students, office workers, taxi drivers and passersby — before, during and after the election.

Of course, it’s not a revolution — not yet, anyway. Although opposition crowds swelled from several tens of thousands at pre-election rallies to perhaps a million or more afterward, the regime controls a vast repressive apparatus. It includes the Iranian Revolutionary Guard Corps (IRGC); the police; the paramilitary, mosque-based Basij; vigilante groups like Ansar-e Hezbollah; the army; and a much-dreaded intelligence service, VEVAK, which was responsible for the assassination of hundreds of dissidents and activists in the 1990s. It’s a fearsome machine prepared to enforce the dictums of Ahmadinejad and Ayatollah Ali Khamenei, the rahbar (Leader), who warned a week after the election that street protests would no longer be tolerated.

And the opposition’s leaders are not exactly revolutionaries. The coalition ranged against Khamenei and Ahmadinejad is a kind of counter-establishment representing a huge split within Iran’s secular and clerical elites. It includes the reformists, led by Moussavi, who served as prime minister during the tumultuous and violently repressive 1980s, and Mehdi Karroubi, a cleric and former speaker of Parliament, both of whom ran against Ahmadinejad. It includes relatively moderate, pragmatic conservatives and the wealthy business elite, typified by the behind-the-scenes role of Ali Akbar Hashemi Rafsanjani, the wily billionaire mullah and wheeler-dealer who was president in the 1990s. And it includes many hardline conservatives from the so-called “principlist” faction, which previously lined up behind Ahmadinejad but this time rallied behind opposition candidate Mohsen Rezai, a founder of the IRGC, who has been bitterly critical of the president and who at least initially claimed election fraud.

But there’s no denying that for the first time since the1978-79 revolution, which led to the Islamic Republic, Iran’s leadership is confronted with an explosive and unpredictable challenge: from below, a mass movement whose street energy and high-tech organizing savvy spread from Tehran to Isfahan, Shiraz, Mashhad and other cities. And within the elite there is a swelling wave of dissatisfaction with the narrow-minded radicals in power, who are blamed for having squandered the country’s oil wealth, mismanaged its economy and forced Iran into a crippling regime of sanctions that have walled it off from the technology and foreign investment it desperately needs.

As a result, Iran is at a crossroads.

In one direction is a slide toward greater xenophobia and ultra-nationalism, in part because the radical forces stirred up among Ahmadinejad’s electoral base will be hard to put back in the box. The broad consensus behind Iran’s system of rule-by-clergy has been shattered, and the Khamenei-Ahmadinejad regime has lost its legitimacy. To shore up support, it’s blaming various greater and lesser satans in the United States, Europe and Israel for Iran’s troubles, making it exceedingly difficult for the country to re-establish ties to the West. At best, Iran will remain embroiled in the stalemate it has faced since 2005, with the economy continuing to unravel. At worst, it could fall into North Korea-like isolation, with fundamentalists and the security establishment preaching that subsistence-level economic privation must be endured for the sake of Islamic purity.

At the very least, the clergy-run, quasi-democratic Iranian state has been replaced by something that looks a lot more like a military dictatorship. Since his election in 2005, Ahmadinejad has installed scores of ex-commanders from the IRGC throughout government ministries and as governors and local officials in all thirty provinces. Ahmadinejad’s cronies have created a powerful clique loyal to Khamenei but, at the same time, encircling the office of the Leader. The conventional wisdom — that the Leader is the all-powerful commander in chief, while the president is an elected figurehead with little real power — may be tilting, if it has not already been turned on its head.

In the other direction, a victory by the opposition — as unlikely as it appears in the wake of the regime’s crackdown — might let in a lot of fresh air. It could smooth the path for an accord with the West, pave the way toward greater cultural and civil liberties, and reverse the downward economic spiral. Under this scenario, Iran could still cling to much of its current form of government, though it would be less rigid. But what scares many conservatives, and no doubt much of the establishment, is that this time it might not be so easy to stuff the genie of reform back into its bottle. A large number of those supporting Moussavi — it’s impossible to know how many — want far more than reform. They want an end to the very idea of an Islamic Republic. Their hero is Mohammad Mossadegh, the prime minister who nationalized Iran’s oil in 1951, challenged the shah and was toppled in a coup by MI-6 and the CIA in 1953. Reform in Iran is a slippery slope, and once reforms get started the very fabric of the Islamic Republic could unravel.

It’s that scenario that Khamenei, Ahmadinejad and their IRGC and Basij allies are determined to resist at all costs. And they’re prepared to unleash Tiananmen Square levels of violence to make sure it doesn’t happen.

A few days before the vote, as Moussavi’s “Green Wave” began to crest, there were already signs that things might get ugly. On June 9 a widely reported leak from the Interior Ministry said that Ayatollah Mohammad-Taqi Mesbah Yazdi had issued a fatwa permitting vote counters to manipulate the results in favor of the candidate who is truly a devotee of Islam. “To you, as administrators of the election, everything is permitted to this end,” Mesbah Yazdi wrote. The ayatollah, who is Ahmadinejad’s chief sponsor among the clerical elite in Qom, Iran’s religious capital, is also godfather to a network of scholars and activists from the ideologically rigid Haqqani School, which he established. For that network — which includes many of Ahmadinejad’s IRGC allies — the word of Mesbah Yazdi is law. The following day, June 10, Yadollah Javani, ideological czar of the IRGC, issued a warning that the regime was prepared to take strong action against the Green Wave movement, which had burst onto the scene to back Moussavi. “There are many indications that some extremist [i.e., reformist] groups have designed a ‘color’ revolution,” said Javani. “Any attempt at a velvet revolution will be nipped in the bud.” It was a chilling reminder of who had the guns.

It was clear by nightfall on election day, June 12, that something was wrong. Across Tehran, troop transports rumbled out of the IRGC’s fortified bases. Before the polls had even closed, Tehran took on the air of an occupied city. Later that night, ominously, my cellphone went dead, like everyone else’s. Not long past midnight, the Interior Ministry declared Ahmadinejad the victor, crediting him with nearly two-thirds of a record turnout, having accomplished the near-magical feat of counting tens of millions of paper ballots in a couple of hours. Later that day, as outrage over what was widely seen as a manipulated result rippled across the city, Khamenei confirmed Ahmadinejad’s win. Hundreds of thousands poured into the streets in protest.

“Moussavi and Karroubi had earlier established a joint committee to protect the people’s votes,” Ibrahim Yazdi, who was foreign minister in the early days after the revolution and who now leads the suppressed Freedom Movement of Iran, told me. “Many young people volunteered to work on that committee. But the authorities didn’t let it happen. Last night [election night] the security forces closed it down.” Describing what the regime did as a “coup d’etat,” he said, “The security forces occupied the offices of many newspapers, to make sure their reports on the election were favorable. They changed many headlines.” Over the next days newspapers were closed, Internet sites blocked or disabled and opposition campaign offices attacked and shuttered. Hundreds of officials, journalists and dissidents — perhaps as many as 2,000 — were arrested, including Yazdi.

Some analysts argue that Ahmadinejad may have won, citing his populist appeal, but that’s farfetched. An analysis prepared by Chatham House in London argues persuasively that the vote was skewed, comparing it with the totals for 2005. It showed that, in at least ten provinces, in order to have amassed the totals given him, Ahmadinejad would have had to win all the voters who backed him in 2005, all the voters who last time voted for Rafsanjani, all the voters who last time sat out the election and didn’t vote at all, and — varying by province — up to 44 percent of the voters who in 2005 backed the reformist slate. Other analyses piled up similar anomalies. One employee of the Interior Ministry told reporters that the ministry “didn’t even look at the vote” but made up the numbers. Said Yazdi, “The counting of the votes took place in the personal office of the minister of the interior, with only two aides present.”

Exactly one week after the election, Khamenei threw down the gauntlet, forbidding street protests and warning of “bloodshed.” He added, “Nothing can be changed. It’s finished, the presidential campaign.” Dashing the hopes of reformers and oppositionists that Khamenei might toss Ahmadinejad overboard to calm the protests, the Leader has steadfastly held to his stance, denouncing peaceful demonstrators as “terrorists” backed by Zionists, “evil” Britain and the CIA. In so doing, Khamenei tethered himself to Ahmadinejad’s presidency, abandoning the pretense that the Leader is above the fray of petty politics. It was as if he’d painted a target on his forehead. In the streets a daring and unprecedented insult to the country’s Leader was heard for the first time in the Islamic Republic: “Death to Khamenei!”

Within ten days of the election, though, the street protests had withered under the unrelenting muscle of the IRGC and the Basij. The regime choked off virtually all opposition communications, arrested most of Moussavi’s campaign staff, shuttered his newspaper and banned him from state-controlled radio and TV. Basij thugs invaded homes to beat people who, at night, climbed to the rooftops to shout their defiance. Round one, at least, seemed to have been won by Khamenei and Ahmadinejad.

As recently as May, Mir-Hossein Moussavi — an architect, artist and president of the Iranian Academy of the Arts, who speaks Farsi, English, Arabic and Turkish fluently — could not have imagined himself leading a throng of followers, some of them calling for the downfall of Khamenei. But in the election’s aftermath Moussavi declared his willingness to be a “martyr,” urged his supporters to take to the streets and issued a series of stirring manifestoes. “A reference point in history is being shaped these days and nights,” Moussavi proclaimed. In direct defiance of Khamenei’s proclamation that the election was over, he said, “I insist that nullifying the election, and recasting the votes, is a nonnegotiable right.” And he denounced the bloody assaults on peaceful demonstrators.

He’d come a long way.

With impeccable establishment credentials honed during his stint as prime minister, Moussavi took sides in a left-versus-right split among the Iranian elite, including the clergy, that resulted in the creation of two broad factions at the end of the 1980s. The left-leaning Association of Combatant Clergy, also known as the Roohanioon, quit the more conservative Association of Militant Clergy, known as the Roohaniyat, which was loyal to the newly inaugurated Ayatollah Khamenei, who succeeded the late Ayatollah Ruhollah Khomeini, founder of the Islamic Republic. Among the Roohanioon leaders were Moussavi, Mohammad Khatami and a group of relatively progressive, open-minded thinkers who became known as Iran’s “reformists.” In 1997, at the end of Rafsanjani’s presidency, the reformists’ first choice to run for president was Moussavi. When he demurred, Khatami ran and — to the surprise of everyone — won overwhelmingly. Moussavi was a key adviser to President Khatami.

The hard right, egged on by Khamenei, counterattacked. It used death squads, vigilantes, secret intelligence units, the Guardian Council and the judiciary to cripple Khatami’s presidency. In 2005, with the backing of the IRGC, the hardliners rallied behind the candidacy of Ahmadinejad, who after his election promptly launched a political, cultural and economic reversal. The IRGC itself became Iran’s most powerful institution. Alongside its military might, it acquired a vast economic empire, from oil and construction to cellphone technology. Suddenly its personnel were everywhere. “The IRGC commanders, both active and retired, act as a kind of fraternity or freemasonry, wielding power that goes far beyond their official positions by virtue of the informal network they operate,” an Iranian insider told me, looking to his left and right to make sure he wasn’t being overheard in a busy Tehran lounge.

When Moussavi decided to run for president this past March, almost no one believed he could get traction. Though his stewardship during the Iran-Iraq war in the 1980s gave him cachet with veterans, like Khatami he is relatively soft-spoken, with little charisma. Secular liberals, leftists and more militant reformists looked askance at Moussavi’s premiership, since it was during his tenure that some of the worst human rights abuses, including mass executions, were carried out. Although it was Khomeini, Khamenei and the secretive intelligence ministry that directed the slaughter, Moussavi did not resign or protest.

Several factors combined to make Moussavi a viable candidate. First, with organizational and financial support from the Rafsanjani family and wealthy mullahs and businessmen tired of Ahmadinejad’s cronies running the economy, Moussavi built a formidable countrywide campaign machine. Second, the brilliant Green Wave strategy, designed by a 27-year-old whiz kid named Mostafa Hassani, caught fire, and soon green ribbons, armbands, headbands, scarves and flags festooned Iranian cities. “I wanted something simple, something that could be replicated even by poor people in remote villages,” the long-haired, lanky Hassani told me, sitting in Moussavi’s cluttered campaign headquarters during election week. And then, on June 3, Moussavi electrified Iran during an unprecedented televised debate with Ahmadinejad. With the president sitting across from him, Moussavi called Ahmadinejad a liar and accused him of pushing Iran toward “dictatorship.” The next day, green-wearing crowds began chanting, “Death to the liar!” and “Death to the dictator!” Nothing like it had ever been seen in Iranian politics.

Moussavi had another not-so-secret weapon: his wife, Zahra Rahnavard. A noted intellectual and sculptor, Rahnavard campaigned alongside her husband, sometimes holding his hand. Clearly a liberated woman, she called for an end to the much-despised harassment of women by the cultural police and backed equal rights for women. At a vast rally in downtown Tehran, I watched her mesmerize the crowd. “We are going to make a revolution in the revolution!” she cried. “We are going to make it modern and up-to-date!” As one, tens of thousands of people chanted: “Moussavi! Rahnavard! Equal rights for men and women!” Women in pink lipstick and with blond highlights in partly uncovered hair shouted beside women in black chadors.

And then there was the Obama factor. Countless Iranians watched his June 4 Cairo speech, and its transcript was parsed word by word. By offering to respect Iran rather than locating it in the “axis of evil,” Obama appealed to secular nationalists, activists seeking greater individual freedom and businessmen hungering for an end to the sanctions strangling Iran’s economy. Nearly everyone I spoke with during the ten days I was in Iran brought up Obama, whether I asked or not. At a frenzied Moussavi rally in the city of Karaj, west of the capital, I met a campaign organizer, Hojatolislam Akbar Hamidi, 48, a distinguished cleric who’s known Moussavi for more than twenty years. “I listened to Obama’s speech, and it made me very happy,” he told me. “But we’re afraid that some Iranian authorities do not understand the positive message of Obama.” In interviews at polling places on election day, dozens of voters praised Obama’s opening to Iran. At a Tehran mosque where hundreds of people were lined up to vote, several dozen crowded around as I asked an older woman why she supported Moussavi. When I suggested, “Perhaps Moussavi and Obama might meet someday soon?” the crowd, translating for one another, erupted in cheers, laughter and thumbs-up signs.

More prosaically, many plugged-in Iranians told me that nearly the entirety of Iran’s business class is fed up with Ahmadinejad’s bellicose rhetoric, and they want to put an end to sanctions. Saeed Laylaz, an economist and former official at the Ministry of Industry, said that as a result of sanctions critical sectors of the economy — including computers and information technology, oil and natural gas, and civil aviation — are suffering badly. “Ahmadinejad’s is the first right-wing government since the revolution, and it has been a catastrophe,” he said. “You cannot run the government with populism. You need experts. You need technocrats. You need planners.” (Laylaz was arrested days after the election; he’s still in detention.) To get a sense of what the business community thinks, during election week I attended a forum packed with executives at the offices of Etelaat, a liberal newspaper, where eight former ministers of oil, industry and mining slammed the government over its incompetence. Later, at Moussavi’s campaign office, one of them, Mohammad Reza Nematzadeh, who was minister of industry under Khatami, told me that he’d put his business on hold to travel across the country working for Moussavi. “I’m a businessman, and I’ve been reluctant to get into politics,” he told me over several cups of tea. “It’s the desire of most of us in the business community to rebuild relations with the United States,” he said. “It doesn’t mean that we have to give up our independence or our dignity.”

Besides reformists, students, women and businessmen, Khamenei and Ahmadinejad are losing their core constituency: the clergy. And given that Iran is a state run by the priestly class, that might prove their undoing. I spoke to a dozen or so clerics, from low- to mid-ranking mullahs to a few who’d attained the rank of hojatolislam, just below ayatollah. There are hundreds of thousands of mullahs in Iran, perhaps a hundred or more who have attained the rank of ayatollah, and just two dozen or so who have developed sufficient reputation and following to be called grand ayatollah. And more and more of them, including many grand ayatollahs, have joined the opposition. “After the television debates with Ahmadinejad, a large number of mullahs who’d been undecided went over to Moussavi,” one hojatolislam told me. They were offended, he said, by Ahmadinejad’s insulting attitude toward Moussavi — particularly his rhetorical assault on his wife, Rahnavard, whom he accused of falsifying her academic credentials — and his accusations against Rafsanjani and Khatami. “A president should be polite,” the cleric told me. “Impolite behavior and ugliness cannot be accepted.”

Another cleric, who campaigned for Moussavi in dozens of Iranian towns and cities, said that the majority of mullahs had abandoned the president. “There is a big gap between Ahmadinejad and the clergy,” he told me. “Many of the grand ayatollahs are angry, because the president has taken many actions without consulting with them. They are especially unhappy because he has shown an aggressive face of Islam to the world, and Islam is not aggressive. It is a religion of peace.” Some three-quarters of the grand ayatollahs in Iran support Moussavi, he told me. Ten of them sent a joint letter to Ahmadinejad, but he ignored them, he said. Several others have openly castigated the regime for its treatment of protesters.

A very well-connected mullah I talked with said that he is a friend and follower of Grand Ayatollah Hossein-Ali Montazeri. Back in the late 1980s, Montazeri was the designated successor to Khomeini as Iran’s Leader, but hardliners — including Khomeini’s son and a circle around Khamenei — ousted him, he told me, because of his liberal views and installed Khamenei. Through this mullah and several other intermediaries, both Moussavi and former president Khatami keep in close contact with Montazeri, as well as with many in the clerical establishment in Qom. In the wake of the election Moussavi and his supporters began organizing what they hoped would be a broad consensus among senior ayatollahs to force Ahmadinejad out or, if it comes to that, to replace Khamenei himself. “Khamenei does not deserve the position that he has,” the mullah told me. “He has become a politician, and as a politician he has been corrupted.” Describing Khamenei in these terms is extremely unusual, and indicates how much the Ahmadinejad-Khamenei axis has lost its legitimacy. “Khamenei has lost the support of many high-ranking clergy in Qom,” declared Ibrahim Yazdi in my interview with him.

Trying to pull together this opposition is Rafsanjani, who so far has stayed behind the scenes but according to numerous reports from Iran is playing a critical role in efforts to counter both Ahmadinejad and Khamenei. The former president is chair of the Assembly of Experts, a group of more than eighty clerics who have the power, under Iran’s Constitution, to appoint or dismiss the Leader. “Rafsanjani has convinced the majority of the Assembly of Experts and several dozen clerics in Qom to support an effort to overturn the election results,” a well-connected Iranian told me. According to Yazdi and several other Iranian activists and analysts, at least some of the clergy want to replace Khamenei with a far more moderate, less political council of ayatollahs as a way of restoring consensus in the leadership [see Sarfaraz, “Iran’s New Revolutionaries,” in last week’s issue]. It would in effect be the end of the Khomeini doctrine of velayat-e-faqih (“rule of the jurisprudent”), which is the underpinning of the notion of a Supreme Leader, a concept invented by Khomeini that is far outside mainstream Muslim, and even Shiite, thinking.

The turmoil in Iran surprised not only Iran’s leaders but America’s. So far, at least, Obama has maintained a measured tone in response to the crisis, condemning the brutality of the crackdown but reaffirming his policy of trying to establish a dialogue with Tehran. He’s resisted calls from ideologues and neoconservatives to adopt a harder line, such as tougher sanctions or overt support for regime change. But realistically, the likelihood of a productive US-Iran conversation is sharply lower now, and it may be months before any such discussions take place, if they happen at all. If, as many Iranian insiders told me in Iran, Khamenei and Ahmadinejad saw value in a rapprochement with the United States before June 12, the explosion since then may have convinced them that now is not the time; at the very least, they will enter any such talks with far less willingness to compromise. On the American side, whatever Obama’s intent, he is now faced with the enormously greater problem of trying to sell the idea of talks with Iran to US skeptics. “This has certainly influenced the public appetite in the US for the Iranian regime, which makes it very hard for the president to…hold the door open for dialogue,” says Tom Pickering, a veteran US diplomat who’s been involved in unofficial talks with Iranian counterparts. “On the other hand, he should be taking the view, if he comes under pressure, that you should be talking to your most difficult enemies. Not talking to them punishes you and your strategic interests, not them.”

If Ahmadinejad and Khamenei retain their iron grip on power, both Iran and the United States will face inevitable pressure to resume diplomacy. “On both sides, the interest in pursuing a dialogue will emerge intact,” says Sir Richard Dalton, who served as Britain’s ambassador in Tehran until 2006. The start of such talks might be “slightly delayed” in the aftermath of the crisis, he says, but that’s hardly a tragedy.

But Obama will have to ignore calls to set a short deadline on such talks. They could easily drag on, well into the middle of next year and beyond. If talks fail to produce immediate results, the president will have to resist arguments from Israeli hardliners and their US allies to take harsh measures against Iran — including military action. Obama’s earlier outreach undercut the hardliners and gave a psychological boost to Iran’s reformists and to millions of Iranians who saw Moussavi as a vehicle through which to improve US-Iranian relations. If Obama wants to support the opposition, the best thing he can do is to continue to extend his open hand to Iran.

Research support was provided by the Investigative Fund at The Nation Institute.