So, let's put things in some context.
The presidential elections of June 12 were held within a theocratic system. In this system, in order to run for a political office, candidates must swear allegiance to the theocratic setup. From its inception, therefore, the theocracy has divided the entire population into two major political groups: khodi (literally meaning, 'of us'; those who support the theocracy), and the gheyre-khodi (the others). This is the exact language used, and participation in the elections are reserved purely for the benefit of the khodi's (believers in the system), who have been divided into different camps from the beginning of the theocracy. In older days, they were split between the left wing, conservative and the pragmatist camps, and more recently the opposing factions have changed some of their tactics and underlying economic policies, and are organized into the 'conservative' and 'reformist' camps. Within each camp, there are further divisions.
Now, let's look at the circumstances of these particular 2009 'elections', bearing in mind again that the election process was and has always been un-free, to begin with.
First, let's look at one particular opinion poll that is claimed to have predicted a landslide win by Ahmadinejad; the poll taken by The Center for Public Opinion (see pdf here)
This poll, taken between May 11 and May 20, indicates a 34% support for Ahmadinejad and 14% for Mousavi; Karrubi and Rezaee receive respectively 2% and 1%. However, 27% of those polled did not know whom they supported. Of those who 'did not know', more than 60%, through their answers to other questions, were characterized by the pollsters as 'reformist minded'. Further, 22% of the respondents are unaccounted for (apparently 15% refused to answer any questions, but the remaining 7% is unexplained). That brings the potential split between the two leading candidates at about 45% for Ahmadinejad and about 30% for Mousavi (discounting the 22% unaccounted).
Further, as the pollsters admitted when releasing their findings, the most likely scenario was, in their view, one in which a second round would be necessary, since they couldn't see anybody having the potential to sweep the elections in the first round.
Further still, in an election campaign, such as it is in Iran, that runs only four weeks, to have concluded an opinion poll in the first week of it, before it has even warmed up, (as somebody said it on TV news) would be akin to basing your ideas of the likely outcome of an American presidential elections based on information gained in an opinion poll conducted nine months or a year before the elections. Not good.