'I wanted to write a book that was big and odd and meandering' … Neil Gaiman at the Edinburgh international book festival, August 2011. Photograph: Murdo Macleod

The way that things look from the inside is never the way they look from the outside. I suspect that this may hold true for everything — families and schools, countries and religions. I know that it is always true of art. The show that the audience sees (slick, polished, spellbinding) is not the show the actors are performing in (the dressing rooms are in the basement. Quick, run downstairs and change your costume! And back up those stairs!). The meal you eat is never the meal the chef prepared, burned fingers and all.

I do not know how American Gods looks from the outside. I've never read it, not to find out what happened next, anyway. I wrote it to find out what happened next, and that's a very different thing.

I know that a lot of people liked it, and that those who liked it, liked it very much. I know that the people who didn't like it, really didn't like it.

But beyond that …

I don't know what it's like to read this book. I only know what it was like to live the writing of it.

I moved to America in 1992. Something started, in the back of my head. There were unrelated ideas that I knew were important and yet seemed unconnected: two men meeting on a plane; a car on the ice of a frozen lake; the significance of coin tricks, and more than anything, America: this place I now found myself living in that I knew I didn't understand. But I wanted to understand it. I was an immigrant, although a reluctant one, and I was living in a huge strange country that resembled the America I'd encountered in books and in films so much less than I had expected. The place was filled with oddness and, it seemed to me, with the kind of hubris that gets authors into trouble, that I thought I ought to point out to Americans how very odd it actually was.

I had a headful of ideas, but no centre.

And then, in the summer of 1998, sleepless and awake-dreaming during a stopover in Reykjavik, I looked down at a tourist diorama of the travels of Leif Erikson, thought: "I wonder if they brought their gods with them, when they went to America?" and it all came together. I went back to my hotel room, wrote a letter to my agent and my editor that explained what the book would be. I wrote American Gods at the top of the letter, certain I could come up with a better title.

The letter finished:

American Gods will be a big book, I hope. A sort of weird, sprawling picaresque epic, which starts out relatively small and gets larger. Not horror, although I plan a few moments that are up there with anything I did in Sandman, and not strictly fantasy either.

It's about the soul of America, really. What people brought to America; what found them when they came; and the things that lie sleeping beneath it all.

That was the goal. That was the destination.

A couple of weeks later, my editor sent me a mock-up of the book cover. It showed a road, and a lightning strike, and, at the top, it said American Gods. It seemed to be the cover of the book I had planned to write. I found it both off-putting and exhilarating to have the cover before the book. I put it up on the wall and looked at it, intimidated, all thoughts of ever finding another title gone forever. This was the book cover. This was the book.

Now I just had to write it.

I wrote the first chapter on a train journey from Chicago to San Diego. I drove from Minneapolis to Florida by backroads, following routes I thought Shadow would take in the book. I ate Cornish pasties in the Upper Peninsula and cornbread Hushpuppies in Cairo, Illinois. I saw strange things and places, and I wrote them down as best I could.

I remember when it was all done in first draft telling Gene Wolfe, who is the wisest writer I know, that I thought I had now learned how to write a novel. Gene looked at me, and smiled kindly. "You never learn how to write a novel," he told me. "You only learn to write the novel you're on."

I had wanted it to be a number of things. I wanted to write a book that was big and odd and meandering, and I did and it was.

I finished it, eventually, and I handed it in, taking a certain amount of comfort in the old saying that a novel can best be defined as a long piece of prose with something wrong with it, and I was fairly sure that I'd written one of those.