|A high turnout had been thought to favour Mousavi, but that appeared not to be the case [Reuters]
By three am local time on Saturday, it was clear that the hopes of Iran's green army, and the anticipation of the international media, had been thoroughly dashed.
What was not clear was quite what had happened in those few hours between the close of voting and the announcement of the initial results, how an enormous wave of sentiment had vanished so completely when faced with the ballot box.
Was it just the failing of the world's press, allowing themselves to become unwitting victim to a clever marketing campaign or allowing itself to be ruled by its own prejudices and preferences?
Or was something else at work?
A walk through the timeline of events might shed some light.
From the opening of the polling stations on Friday morning, the length of the queues suggested something unusual was under way.
By the time the Guardian Council began speaking in the early evening of a turnout approaching 70 per cent, most people had concluded even this was a low-ball estimate.
Opinions having long gelled around the proposition that high turnout equals reformist victory, the mood among journalists gathering at the interior ministry - roads blocked, access restricted, riot police in evidence - was of anticipation and bemusement.
Could it be that, yet again, an outside candidate had come from behind to win in the first round?
Word was circulating that Mir Hossein Mousavi, the main reformist challenger, would be giving a press conference late on Friday night when, at 11pm [18:30 GMT], the ministry press room was told to expect Kamran Daneshjou, the elections chief.
Few people anticipated much more than general background information, and perhaps some hints as to the progress of the count; it was assumed to be far too early for any definitive results.
Daneshjou failed to appear. Instead, a buzz spread around the room. The Islamic Republic News Agency (IRNA) had a new lead story: Ahmadinejad was streaking ahead in the vote in the countryside.
IRNA is a government controlled agency, and some of the local media were sceptical of the story.
But the pro-Ahmadinejad camp was lifted in particular by the claim that the city of Rafsanjan, home town of Akbar Hashemi Rafsanjani, a former president, had voted 90 per cent in favour of Ahmadinejad.
They were relishing the symbolism of such a heavy rejection of the arch foe.
Moments later word came through that Mousavi had held a news conference to declare outright victory.
A senior member of his campaign told me that their election monitors at polling stations were certain that the trend strongly favoured their candidate.
Moments later, at 11.50pm [19:20 GMT], Daneshjou appeared.
We were told there would be no questions. The counting so far, he said, involved 8,000 ballot boxes, some five million votes, and the returns showed Ahmadinejad with 69 per cent of the vote and challenger Mousavi with less than 30 per cent.
The pattern had been established. As in US presidential elections, it would be the television stations and news wires that led with figures that would only later be confirmed by the interior ministry.
The state-run TV station is regarded as a reliable reflection of official numbers, and the news from sources inside was that they were close to declaring outright victory for Ahmadinejad.
|Mousavi's claim of victory was quickly rejected by the interior ministry [Reuters]
At 12.20am [19:50 GMT], Daneshjou had an update.
A further 8,000 boxes had been counted in the past 30 minutes, and the president was still leading with almost 69 per cent of the vote.
At this point, one of the more alert journalists pointed out that the initial announcement had spoken of "baazshomari" - recounting.
The numbers we were hearing were not a running tally, but a reconfirmation of what was an already established result.
Indeed, not long after, the Ahmadinejad camp not only declared outright victory, but framed its claims in historic terms: this victory erased the record turnout that had swept Mohammad Khatami, the previous reformer, to power in 1997, and confirmed Mahmoud Ahmadinejad, a principalist, as the most popular leader in the history of the Islamic Republic.
Breakdown of the vote in individual districts was still patchy, but there were a few results that raised eyebrows.
Ahmadinejad had apparently taken the northwestern city of Tabriz with some ease.
Tabriz is the heart of East Azerbaijan, and Azeris are among the tightest ethnic groups in the country, unfailingly voting along ethnic lines.
In the 2005 presidential election, Mohsen Mehralizadeh was a largely unknown and wholly unsuccessful candidate. He came in seventh and last, and yet he still won the Azeri vote in the Azerbaijani provinces. Mir Hossein Mousavi is an Azeri from Tabriz.
Elsewhere, Mehdi Karroubi failed to take his home state of Lorestan; in Khuzestan, Mohsen Rezai, a local scion, was expecting at least two million votes. His total for the entire country has failed to breach one million.
And with each updated count, Ahmadinjad's lead did not waver from a very stable range of 66-69 per cent, irrespective of which districts were reporting.
After 3am [22:30 GMT], the interior ministry went quiet for the night. Out on the streets, some groups of youths were driving the streets in celebration. But not 69 per cent of them.