The honeymoon is over. Iran's controversial president, Mahmoud Ahmadinejad, has finally come unstuck. His popularity with the Iranian electorate - the subject of much incredulous analysis in 2005 - seems to be falling back at last, and the country's latest exercise in populism seems to be reaping the rewards of unfulfilled promises bestowed with little attention to economic realities.

Those realities have sharpened with the onset of UN sanctions. Ahmadinejad's casual dismissal of the sanctions has apparently earned him an unprecedented rebuke from the supreme leader, Ayatollah Khamenei - reflecting growing concerns among the political elite, including many conservatives, who are increasingly anxious at Iran's worsening international situation. As if to emphasise this point, Hashemi Rafsanjani, Ahmadinejad's defeated foe in the 2005 presidential election, echoed the condemnation of the president's public complacency, stressing that the threats against Iran were very real. Indeed, as a second US carrier group heads for the Gulf, there is belated questioning of the president's competence. His critics argue that not only does he appear to have courted the anger of the US, but his economic mismanagement and political nepotism have weakened the internal integrity of the Islamic republic - and proved to be a gift to Iran's enemies.

Ahmadinejad was elected on a platform of anti-corruption and financial transparency, and few appreciated how rapidly he was intoxicated with the prerogatives of his office. He very soon forgot the real help he had received in ensuring his election, basking in the belief that God and the people had put him in power. Ahmadinejad soon had a view for all seasons: uranium enrichment. Of course Iran would pursue this, and what's more, sell it on the open market at knockdown rates. As for interest rates, they were far too high for the ordinary borrower, so cut them immediately. And then there was the Holocaust.

None of this might matter so much, if the president had based his rhetorical flourishes on solid policies. But much to everyone's surprise nothing dramatic materialised. Ahmadinejad appeared to follow the dictum of his mentor, Ayatollah Khomeini - "Economics is for donkeys". Indeed, his policies could be defined as "anything but Khatami" (his predecessor). So the oil reserve fund was spent on cash handouts to the grateful poor, and the central bank, normally a bastion of prudence, was instructed to cut interest rates for small businesses.

These had the effect, as Ahmadinejad was warned, of pushing up inflation. The rationale for high interest rates was to encourage the middle classes to keep their money in Iran. Now they decided to spend it. Richer Iranians, worried about rising international tension, decided it would be prudent to ship their money abroad. This further weakened the rial, and added to inflationary pressure. In the past few months the prices of most basic goods have risen, hurting the poor he was elected to help. Moreover, far from investing Iran's oil wealth in infrastructure to create jobs, he announced recently that Iran's economy could support a substantially larger population, as if current unemployment was not a big enough problem.

Views such as these, along with his well publicised unorthodox religious convictions, have earned him the ridicule of political foes. What is more striking perhaps is the growing concern of those who should be considered his allies, especially in the parliament. These are people who supported him and expected results. They expected their populist protege to overturn the heresy of reform.

Much to their irritation, not only has Ahmadinejad singularly failed to consolidate and extend his political base, the recent municipal elections saw his faction defeated throughout the country. Traditional conservatives and reformists reorganised and hit back, ingeniously using technology to work round the various obstacles placed in front of them. Now, over the past weeks, with biting weather, shortages of heating fuel are further raising the political temperature, while his political opponents point to the burgeoning international crisis for which the globetrotting president seems to have no constructive answer. Talk has turned to impeachment.

Ironically, it is this very international crisis that may serve to save Ahmadinejad's presidency, a reality that the president undoubtedly understood all too well. As domestic difficulties mount, the emerging international crisis could at best serve as a rallying point, or at worst persuade Iran's elite that a change of guard would convey weakness to the outside world.

There can be little doubt that US hawks will interpret recent events as proof that pressure works, and that any more pressure will encourage the hawks further. Yet the reality is that while Ahmadinejad has been his own worst enemy, the US hawks are his best friends. Ahmadinejad's demise, if it comes, will have less to do with the international environment and more with his own political incompetence. There is little doubt that it will take more than a cosmetic change to get Washington to listen to Iran. But the real question mark, as the Baker-Hamilton commission found to its cost, is whether Washington is inclined to listen at all.

· Ali Ansari is director of the Iranian Institute at the University of St Andrews.

aa51@st-andrews.ac.uk