AFTER the day of fasting comes the night of feasting. For Iranians, the familiar rhythm of the Muslim holy month of Ramadan brought an entirely different sort of celebration on the night of July 14th. With the breaking of the fast after sundown, the streets of Tehran burst with jubilant cheering, flag-waving and the blasting of car horns to rejoice at the signing of a momentous nuclear accord between Iran, America and five other world powers. As one celebrant put it, Iran had endured a political and economic fast lasting 36 years; it was at last rejoining the world.

The normally perfunctory state television and radio gave live coverage to the closing days of the arduous negotiation in Vienna. And when the deal was signed, it broadcast not only the comments of the suave, ever-smiling foreign minister, Mohamad Javad Zarif, but also those of Barack Obama, the American president. The message was clear: sanctions and diplomatic isolation were coming to an end.

The interior ministry, usually suspicious of uncontrolled crowds, declared the streets open for celebrations. Revellers danced past midnight. Even outside the old American embassy, the “den of spies” that had been taken over by students after the Iranian revolution in 1979, people sounded their horns. “This is the end of ‘death to America’, and the start of a rapprochement,” said a Tehran-based analyst, Ramin Mostaghim, who joined the crowds.

All sides in the negotiation insist that the accord is limited to resolving the crisis over Iran’s nuclear programme, at least temporarily. But all believe it is about much more than uranium-enrichment centrifuges and the modalities of inspections, important as these may be (see article). The potential to normalise relations between Iran and America, embittered since the revolution, could change the balance of power in the Middle East, transform America’s role and, perhaps, change the course of Iran’s politics.

During his inaugural address in 2009, Mr Obama told Iran that America “will extend a hand if you are willing to unclench your fist”. Now after much bargaining the two sides have shaken hands—even though the ayatollahs have yet to unclench their fist at home, sheath the sword abroad or abandon their nuclear ambitions (which Iran claims are peaceful and the West says are aimed at developing the ability to make atomic weapons). If it works, the accord will contain Iran’s nuclear capability for at least 10-15 years. The hope is that, in the meantime, Iran and the region will have changed profoundly.

The most obvious consequence will be economic. Unlike its richer Gulf neighbours, Iran is not an oil-soaked rentier state, but a regional power with an industrial economy and lots of educated people who work.

A new economic motor

Alone in the Gulf, it manufactures (and even exports) its own cars. For all its petrodollars, Saudi Arabia could not match Iran’s nuclear programme without outside help. Mismanagement under the hardline former president, Mahmoud Ahmadinejad, as well as corruption, sanctions and the collapse in oil prices, have shrunk economic output from $248 billion in 2011 to $231 billion in 2014 (in constant 2005 dollars); export revenues have fallen by a third in the same period. Yet isolation has also fostered self-reliance. When Peugeot, a French carmaker, withdrew as a result of sanctions Iran engineered its own (cheap but substandard) parts. Iran’s largest petrochemicals manufacturer boasts 44,000 employees, all of them Iranian.

For most Iranians, the nuclear deal offers the promise of prosperity. Under its terms, the world would unfreeze over $100 billion in assets and let Iran sell its oil worldwide. Iran predicts it will be able to double its oil exports within six months. The harshest sanctions will not be eased until early next year, after the international inspectors verify Iran’s compliance. The supreme leader, Ayatollah Ali Khamenei, has set a target of 8% average annual growth for the next five years, up from its current 2.5% (see chart). Some Western diplomats and financiers in Tehran reckon that, within a decade, Iran’s GDP might surpass that of Saudi Arabia and Turkey, the regional economic powerhouses.

So many Western delegations have turned up in Iran in anticipation of a bonanza that its airport has opened a Commercially Important Persons lounge, alongside its VIP one. Iran plans to unveil new oil-exploration tenders at a conference in London in September. The bedraggled national airline has been holding videoconferences with Boeing every week, gripes an official from its European rival, Airbus. Logistics and Islamic tourism holds much promise. The biggest prize is hydrocarbons: Iran has the world’s fourth-largest oil and second-largest gas reserves, but sanctions and antiquated technology make these hard to extract.

The China model, not the Russian one

Western supporters of the accord hope that, over time, the opening of the economy and diplomatic normalisation will also open up its political system and release the pent-up pro-Americanism of Iran’s urban classes. In contrast with the Arab world, religion in Iran is conspicuous by its retreat from public life; relatively few people fast during Ramadan. Mr Khamenei seems to be counting on prosperity having the opposite effect—that of consolidating the regime. Rouzbeh Pirouz, who heads Turquoise Partners, an investment house, says the leader is trying to engineer a Deng Xiaoping moment, not a Mikhail Gorbachev one. He may be succeeding. “The negotiations have brought the people and the regime closer together,” says one reform-minded ex-official. “Never has the regime looked so strong.”

In a sense, the nuclear deal is the culmination of a seven-year process of narrowing the gap between the regime and its people. After the near-rupture of 2009, when the regime ensured the re-election of Mr Ahmadinejad and crushed the protests known as the Green revolution, the ayatollahs have rolled back some of their more heavy-handed policies. They have eased the intrusions by the Basij, the paramilitary force responsible for public morality. Where once it enforced a ban on short-sleeves, the Basij now hands out black T-shirts to members. “It’s a bit overzealous to hide one’s elbows,” explains a local leader.

President Rouhani, a relative centrist elected in 2013, has curbed the profligacy of Mr Ahmadinejad, who emptied state coffers, parcelled out over $700 billion of assets to loyalists (especially the Revolutionary Guards) and triggered inflation topping 40%. Senior figures around Mr Ahmadinejad have been detained on charges of embezzlement. And the regime has embarked on what the supreme leader calls “heroic flexibility” in the nuclear negotiations (starting with secret talks in Oman in 2012, before Mr Rouhani’s election). In return Iran’s reformists have refrained from directly challenging clerical rule and mostly back Mr Rouhani. Today’s nonconformists lead rebellious private lives, rather than public ones.

Here and there, too, there are pockets of hardline scepticism. A large poster hung on the side of a building in Tehran still compares Mr Obama to Shemr, a seventh century villain in Shia Islam, albeit through the grime accumulated over two years. The most vociferous hardline newspaper, Keyhan, quickly called on parliament to scrutinise the deal to see whether it had crossed any of the supreme leader’s declared red lines (which it has). Others warned Iranians against celebrating a “false victory”.

Yet such objections are muted. One reason is that the supreme leader has made clear his support for the deal, wasting no time in praising the negotiators and hosting them for a Ramadan breaking of the fast. Another reason is that at least some hardline factions stand to gain from the lifting of sanctions. So extensive has the conservatives’ network of banks, mobile-telephone companies and oil firms grown in the absence of Western competition that foreign firms seeking access to the Iranian market may have to knock on their doors.

Many suggest that the “new horizons” that Mr Rouhani speaks about go well beyond financial matters. Cries of “Death to America” are still chanted at Friday prayers. But these sound hollow amid the euphoria of Iran’s “deal with America”. One hotel receptionist abandoning his desk to join the jubilant crowds said: “It’s over. We will have peace, and after a month America will reopen its embassy and the good man, President Obama, will visit Iran.”

That is certainly too optimistic. But words like “game-changer”, “huge deal” and “reorientation” trip from the tongues of officials. Even before a nuclear deal was in the bag, Iranian officials posited the idea of negotiating a counter-terrorism deal.

Iranian officials argue that, for all the enmity, Iran has been a more reliable partner for America than its Arab allies. It acquiesced in the toppling of the Taliban in Afghanistan—though they are now hosting them in Iran as potential bulwarks against the jihadist tide of Islamic State (IS)—and co-operates on the ground in Iraq against IS. America and Iran worked together to replace the Iraqi prime minister, Nuri al-Maliki, with a more pliable successor, Haider al-Abadi. Some think co-operation may yet extend to finding a way of replacing Syria’s president, Bashar Assad. Iranian officials hold out the prospect of a gas pipeline via Turkey to Europe, easing Europe’s dependency on Russian gas.

Iran is not as unfamiliar with the West as it may seem. Mr Rouhani’s cabinet boasts more American doctorates than Mr Obama’s. Hossein Moussavian, a former Iranian nuclear negotiator, wrote this week in the Daily Telegraph, a British newspaper, that the nuclear agreement will give America “an option that it has never had before: the opportunity to escape the total reliance it has had for decades on its freeriding regional allies”, ie, Israel and Saudi Arabia. Indeed, the prospect of even a partial American realignment helps to explain the public denunciation by Israel, and the private but no less vehement comments from Gulf rulers.

And yet, without change from Iran on the question of Israel and Palestine, any rapprochement will be limited. Some already detect a quiet shift. Where once the supreme leader spoke of a “resistance front” against Israel, his advisers more readily deploy the term against IS.

The real ideological venom is now directed towards Saudi Arabia. Senior Iranian figures openly call for the overthrow of the House of Saud, and suggest that rather than striking IS, the junior Wahhabi entity, it should target its Saudi “parent”. Iran shows no sign of easing the military and diplomatic support it offers its clients in various regional conflicts, from Mosul in the north to Aden in the south—and it may increase support once sanctions are lifted. “Those who have lost prestige and power internally may try to regain it elsewhere in the region,” says Kevan Harris of the University of California, Los Angeles.

For all the anticipation of better times, decades-old mistrust is institutionalised. In the eyes of some Iranians, America is following the model it used to oust Saddam Hussein in Iraq: apply harsh sanctions on oil exports, demand intrusive inspections, use them to infiltrate intelligence agents and then exploit violations to bring down the regime. Nor do such hardliners believe compliance will offer much of a safeguard: Muammar Qaddafi’s decision entirely to dismantle Libya’s nuclear programme did not stop Western countries from helping his foes to overthrow and kill him.

Long time coming: Iran's atomic agreement Sky-high hopes at home, too, could easily turn sour. Sanctions are only one of the problems bedevilling Iran’s economy; grinding corruption and bureaucracy could similarly hamper foreign investment. With parliamentary elections only seven months away, conservatives are already expecting to capitalise on discontent should the promised fruits from sanctions relief be slow in ripening.

Remember the betrayal of Ali

Set against the prospect of their comeback, though, is the ineluctable dimming of Iran’s revolutionary ardour. In the last days of the nuclear talks in Vienna, ideologues clad in black crammed into a modest living room in north Tehran, turned the lights low and mourned the killing 1,354 years ago of Imam Ali, whom Shias regard as the Prophet Muhammad’s first righteous successor. The gathering included university lecturers, writers and international lawyers. They wept, wailed and beat their breasts. Bemoaning the latest dark turn of events, they called on God “to help us now”. Just as Ali was betrayed, said one participant, “we know that the West will deceive us”.

But after the lights came back on, and the gathering feasted on dollops of fesenjan, a stew of pomegranates and soft walnuts, one lawyer admitted: “Eighty-five percent of Iranian women no longer wear a proper veil. Even the hardliners aren’t radicals anymore.”