Ahmadinejad really does believe that there are no homosexuals in his country. And at the same time there are routinely executions of homosexuals. This is well-documented. The executions are by hanging most of the time. And not just hanging, but slow strangulation. Rather than dropping the victim through a door in the floor, they are pulled upwards by the noose.
Of course, homophobia is not a specifically Islamic issue, but in Iran and a few other Islamic countries, it sometimes takes an extreme form. I guess part of the explanation is the Holy Book, as it is for Christian homophobia. Another part is this: the Islamic self-image is derived from anti-western views. The west is viewed as decadent. Homosexuality is seen as a symptom of this decadence, like pornography, democracy etc. Hence it is difficult to accept that some part of this “decadence” can be found in Islamic countries as well.