Just last week, an article by Seymour Hersh, the respected US investigative reporter, which claimed that the war against Iran's proxy Hizbullah was a premeditated US-directed warm-up for an attack on Iran itself, stoked fears in Tehran that a US air assault on its nuclear facilities, even regime change, are moving to the top of the agenda. Officials in Tehran worry that, after Afghanistan and Iraq, Iran is seen by Bush as "unfinished business" - and that, urged on by Israel, he is determined to destroy what both countries see as the looming threat of an "Islamic bomb". They hear Bush's talk of "Islamic fascists" - and wonder whether he will soon be gunning for them.

There is a way out. Tomorrow the Iranian government will present its long-awaited response to the west's last-ditch compromise offer on nuclear power. This package, belatedly backed by the US, offers Iran a range of incentives from implicit security, territorial guarantees and an end to sanctions, to new commercial and technological collaborations. But first, Bush insists, Iran must suspend all uranium enrichment operations, which Washington believes are connected to its attempts to acquire bomb-making capability.

So far, Iran has insisted that it will not accept any such pre-conditions. Officials say they are willing to resume negotiations with the west - but on equal terms. So when Ahmadinejad delivers Iran's formal reply at a Tehran press conference, the stage will be set for an epic clash that could reverberate across the Middle East and far beyond. So far, the story has mostly been reported from the outside, and from a western perspective. But what are the prospects for war and peace as seen from inside Iran? For the past two weeks the Guardian has been given unprecedented access to explore what ordinary Iranians think about the most pressing issue facing their country - and what some of the country's most powerful men believe will happen next.

'Diplomatic chess'

In a high-ceilinged, thick-carpeted inner sanctum of Iran's fortress-like Supreme National Security Council building in central Tehran, Ali Larijani patiently spells out the factors that will play a part in Iran's decision. The CIA would dearly love to penetrate inside these walls. Perhaps it already has; visitors' mobile phones and other electronic devices are confiscated.

Larijani is an important man in Iran. As secretary of the security council and chief nuclear negotiator, it is he, and his predecessor, Hassan Rowhani, who have by turns tantalised, teased and infuriated the west during three years of discussions on the nuclear dossier. Iran plays a long and astute negotiating game, which Larijani likens to "diplomatic chess". Officials say they learned at the feet of masters: the European powers who exploited Persia during the 19th century "Great Game". Britain is still referred to as the "Old Fox".

Larijani has a daunting reputation as the dour former head of state television whose programme schedules were both morally edifying and utterly tedious. His appointment by Ahmadinejad was seen in the west as representing an ominous shift towards recalcitrance. But in person he is charming and courteous.

"There are many reasons why Iran is seeking nuclear power," he says. "The history of our nuclear activity dates back 45 years to the time of the ex-shah's regime. But after the Islamic revolution, some western countries condemned Iran and cancelled their nuclear agreements with us. For example, the Americans had concluded an agreement for a research reactor in Tehran and also to provide the fuel. But they cancelled the agreement and did not give back the money. The Germans did the same. So the lesson was: we have to be self-sufficient, to provide fuel for ourselves."

He continues: "We don't see why we should stop the scientific research of our country. We understand why this is very sensitive. But they (the west) are categorising countries. Some countries can have access to high nuclear technology. The others are told they can produce fruit juice and pears! They say: 'Don't seek a nuclear bomb.' We don't have any objection to that. But unfortunately officials of some countries such as the UK say, 'We don't want you to have the knowledge for nuclear technology'. This is not logical. And we don't pay attention to this."

The Americans' contradictory impulses are to blame for the standoff, he says. "After September 11 2001, they faced a problem in Afghanistan. They requested assistance from Iran and we gave it. But after the problem ended in Afghanistan, they called us the 'axis of evil'. This paradox has always been their way. They want to kiss one side of our face, but at the same time they also want to slap the other side."

Iran is still willing to negotiate, Larijani concludes, but it will not give up its nuclear power programme. Nor will it yield to preconditions such as Bush's demand for an immediate suspension of uranium enrichment. "If they are going to seek an imposed agreement by putting pressure on us, we will not accept it. If the atmosphere is not proper, we may delay our reply. If you try to cultivate a flower in salty land, it does not grow."

For Larijani, the bottom line is respect. And the evident lack of it in Washington, magnified by loose talk of enforced regime change, is one of many reasons why Iran is going nuclear.

A changing society

Tehran is a city of elegant parks. And none is more serene than Saee Park, off Vali Asr Avenue, one of the capital's main thoroughfares. Known as the "lovers' park", it is where young and not-so-young couples sit at dusk beneath a canopy of fragrant chinar, cypress and pine trees, exchanging gossip and intimacies, sharing ice creams and swapping phone numbers.

According to Reza, 27, and his girlfriend, things are more easy-going socially than they were 10 years ago. They attribute the change to the presidency of Mohammad Khatami, Ahmadinejad's reformist predecessor. Despite Ahmadinejad's conservative instincts, the new government has been unable to put the street culture genie back in the bottle, Reza says.

"There's more personal freedom. You don't get harassed like you used to. The young people are changing the older people's attitude. They have to accept it - they have no choice, so they go with the flow." And in a country of 70m, where two-thirds of the population is under 30, the trend appears irreversible.

The present hardline government is not popular among many inhabitants of Saee Park. They complain about its failure to expand and diversify an economy that is roughly 80% state-controlled. Younger people worry about careers and jobs, about the difficulties of foreign travel and internet censorship, about the lack of things to do and places to meet. Leila, 27, says she would like to go to parties, to clubs; she would like to sing. "But they won't allow female singers, did you know that? Female vocalists are banned. They say they are too alluring to men. Poor men! They have weak brains!"

Yussuf, 63, has a different perspective. "I was a metallurgist until I retired. I trained in the US during the Shah's time. I worked all my life. But now I have to take part-time jobs because my pension isn't enough. This government is no good, they're all no good." Yussuf has another complaint: the government is sending money to Hizbullah in Lebanon that would be better spent at home, he says. "First you must look after your own people."

His friend, Ali, agrees. He wants to know into whose pockets Iran's record oil revenue is going. "Some of them [the governing elite] are buying cars for $100,000. Think of that! Did they get that money by working?"

All the same, Ahmadinejad's personal brand of nationalist populism, typified by his defiant handling of the nuclear issue, has many admirers in Saee Park and beyond. "Why don't they just leave us alone and let us live under our own rules?" asks a 32-year-old engineer.

"Iran has the right to nuclear power," chanted a crowd in Ardabil, in northern Iran, last week. During a series of nine rallies addressed by Ahmadinejad, the sentiments expressed by ordinary people are the same. Western attempts to deny Iran nuclear technology are "an obvious attempt to keep us down, like they want to keep all the developing countries down," says Majid, a 30-year-old teacher in Tehran. "We don't want nuclear weapons. But we want to build our country. What's wrong with that?"

Iranians may be cut off from the modern western world in many ways, but they are well versed in the long history of western intervention in Persia. From the Treaty of Golestan in 1813, by which Russia took control of Iran's Caucasus territories, to the 1953 CIA-led coup that toppled Iran's democratically elected prime minister, Mohammad Mosaddeq, from the US embassy hostage siege to the Iran-Contra scandal, a tale of national subjugation and degradation forms the context in which Iran looks at the west. And Iranians hear, in derogatory western talk of "mad mullahs", an echo of a 19th-century British diplomat's sneering reference to "incomprehensible orientals". It smacks of disrespect.

And now, with Washington's neo-conservatives on one side and Ahmadinejad's neo-conservatives on the other, this mutual antagonism and misunderstanding is coming to a head. In some analyses, it has brought the two countries to the brink of military conflict. If the US attacks, experts say it is likely to take the form of "precision strikes" on the four main nuclear facilities and possibly Iranian armed forces and Revolutionary Guard bases, too. But Pentagon planners know Iran has the potential to retaliate, as the unexpected success of Hizbullah in Lebanon has shown. This week the US ambassador to Iraq highlighted what he said were Iranian attempts to push Shia militants into attacks on coalition forces in Iraq. And Baghdad is only one possible theatre for Iranian reprisals should the US pull the trigger.

Mohammad Saeidi is a practical man. Sidestepping the political, ideological and historical aspects of the nuclear dispute with the west, the vice-president of Iran's Atomic Energy Organisation is focused on a set of problems that must be solved logically if the country and its people are to develop to their full potential. "The country's oil and gas reserves will last a maximum of another 25 or 30 years," he says. "Therefore we have to provide other resources."

About 7,000 people work in Iran's atomic establishment - principally in Tehran and at the Bushehr, Arak, Isfahan and Natanz complexes. Saeidi says there are plans to build 20 nuclear power stations in all, at a cost of $24-$25bn. The first, at Bushehr, built with Russian help, is expected to come on stream next year. Saeidi says that in going nuclear Iran is only following the example of other countries with growing populations and rising energy demand. Nuclear power is cheaper, and its raw component, naturally occurring uranium, is in plentiful supply in Iran's central deserts.

It is the cascade of 164 centrifuges constructed at Natanz that has drawn most international attention since Ahmadinejad announced last April that Iran had mastered the processes for uranium enrichment. It was Natanz that finally prompted the US to join with European negotiators in offering the compromise incentives package that is now on the table. But like Larijani, Saeidi stresses the research stage nature of this work - and the ongoing inspections of Natanz and other plants by the International Atomic Energy Agency.

To try to divert nuclear material for bomb-making purposes without the UN knowing would be "impossible", he says, and if a deal is struck, Tehran would be ready to reintroduce spot checks. But, in any case, bomb-making is not Iran's aim, Saeidi says - even if it had the capacity, which it does not. Overall, independent experts tend to agree that, at present, Iran does not have the wherewithal to build a nuclear weapon. But that does not mean it will not in future.

Saeidi denies that Iran kept its facilities at Natanz secret, as claimed in 2003 by the Bush administration. He says there was no legal necessity to notify the IAEA before nuclear material had entered the plant. "Natanz is a very large factory. You cannot hide it. It wasn't secret."

He also denies receiving help from Pakistan, now or in the past, despite a spate of disclosures concerning the proliferation network run by the Pakistani scientist, AQ Khan. "We don't have any relation to Pakistan on the nuclear issue. All the equipment and components we are using are made by Iranian companies and factories."

Needless to say, such statements are disputed by the US and other western governments who suspect that Iran may be running a hidden, parallel uranium enrichment programme using more advanced centrifuges. They worry it is also experimenting with plutonium reprocessing. But all such claims are met with a flat denial.

"We don't have any secret programme. We don't have any secrets," Saeidi says. Iran does not want the bomb, he and other officials insist; and it has no plans to build one. What it does want is a plentiful future supply of nuclear energy to fuel the rise of a new, more powerful nation - and in this ambition, it will brook no obstacles.

Ahmadinejad's vision

The man who could make all the difference is Ahmadinejad himself. He insists that Iran's intentions were not to make a bomb - "Iranians have mastered the complete cycle of uranium enrichment by themselves. But we will use it for peaceful purposes, for nuclear power. This is our right and no one can take this right away from us." But the man best known in the west for his desire to "wipe Israel off the map" and his questioning of the Holocaust, this blacksmith's son who rose to be mayor of Tehran before unexpectedly winning the presidency a year ago this month, is a controversial figure inside Iran, too. Many people, largely among the working class and in rural areas, adore him. Others, particularly among the intellectual elite of Tehran, fear his devout Islamic beliefs and his conservative political instincts will further isolate the country.

For Iran's president is a true believer. He maintains that the 1979 revolution that overthrew the shah was besmirched and betrayed after the death of its leader, Ayatollah Ruhollah Khomeini, by pragmatists and corrupt mercantilists, by pro-western compromisers and reformists. Ahmadinejad's famously humble lifestyle, emphasised by his rumpled jackets and unkempt beard, offers but one clue to the fundamentalist spirit that moves him. Tehranis say his vision is a return to the ideals of 1979, including a reinvigorated social conservatism, a revived popular piety, and a principled rejection of the Christian and Zionist "crusader" west.

Many political moderates, western diplomats and ordinary citizens say Ahmadinejad's vision is to turn the clock back to a more honest and more dutiful time. And what better way to demonstrate the uplifting virtues and potency of this religious retrenchment than defiance of the west over the nuclear issue? Here is a golden opportunity to re-affirm Iran's compromised independence and dignity - and restore both the international respect and the religious values that Ahjmadinejad believes the revolution has squandered since 1989. This is Ahmadinejad's chance.

It may be naive to believe that Iran's government, surrounded by nuclear-armed neighbours and directly threatened by the US, is not seeking to acquire a nuclear weapons capability. "The Americans have been seeking regime change in Iran ever since the victory of the revolution," say Larijani. Given such widespread convictions, and the example of several other countries that have built atomic weapons without facing serious penalties, Iran's leaders might be thought remiss in not seeking to arm themselves.

But more naive, perhaps, and potentially even more destabilising, is Ahmadinejad's apparent belief that by confronting the west over the nuclear issue, he can revive the purist, Khomeini-era ideal of fundamentalist Islamic revolution in a country that is changing rapidly. Most Iranians support the government's pursuit of nuclear power. But most oppose the intolerant theocracy that is Khomeini's legacy.

In his brilliant new book, Confronting Iran, Ali Ansari portrays the growing "secularisation" of Iranian society as an unstoppable force. "Fewer and fewer people show an interest in organised religion," he writes. And in Tehran the evidence of that is everywhere. Iran is a rich country, poorly run. Slowly but surely its people are demanding and obtaining change. Iran does seem destined once again to be a great regional power, but that destiny is likely to be attained despite its religious leadership - and despite the Bush administration's counter-productive bullying.

Ahmadinejad, the articulate champion of Iran's national rights, is a potent figure. But Ahmadinejad, the would-be visionary leader of a resurgent revolution awaiting the coming of the Hidden Imam, is living a dangerous illusion. And it is Iranians, not the US air force, who should be allowed to shatter his dream.