As a 13-year-old Richard Dawkins would fantasise about praying at an altar then seeing an angel dramatically appear in a burst of white light. Yes, one of the world's most strident atheists communed with God – "but God never actually did get through to me for some reason".

Dawkins' religious fervour lasted about two years, he told the Edinburgh International Book Festival on Wednesday.

"I was briefly seduced by it and took it all in and would pray very vigorously every night," he said. But, he added, he had never acted on his angel fantasy. "I never tried the experiment. I shall never know if it might have happened."

Dawkins has since become the scourge of all religions but he denied that he relished "being hated". Nonetheless he had made a YouTube video which showed him reading his hate-mail in front of a log fire; and the next video, he said, would feature a cello player to give some atmosphere to it. He said: "I don't mind being disliked by complete idiots."

In that category, Dawkins said, would be many creationists. He now refused to appear on the same platform with them since it gave credence to their views.

Dawkins was asked whether his statements on fundamental Islam might demonise moderate Muslims? He hoped not. "It is very important that we should not demonise ordinary, law abiding, very decent Muslims, which of course are the vast majority in this country," he said.

But he argued that moderate people of any faith "make the world safe for the extremists" because they legitimised believing "something without evidence, without the need to justify it". He said such a view gave licence to extremists, letting them say, "my belief is I'm supposed to be a suicide bomber or blow up buildings – it is my faith and you can't question that".

Dawkins accepted that most moderates would be "horrified" at the suggestion they were helping fuel extremism. "I'm sure they'd be horrified, nevertheless it could be true."

Dawkins, best known for his books The Selfish Gene, and The God Delusion, was at the festival in Scotland, which is being staged in association with the Guardian, also to talk about his memoir, An Appetite for Wonder.