Cult novel Good Omens, by Neil Gaiman and Terry Pratchett, has been adapted for radio. Here Neil Gaiman tells the story of how it came to be written.

For the uninitiated, Good Omens is a story about how the world is going to end next Saturday. Just after tea. And how the only things standing between us and the inevitable Armageddon are a demon, Crowley, and an angel (and rare book dealer), Aziraphale, who are, rather uncomfortably, working together, not to mention a witch, a very small witchfinder army, the Antichrist (who is 11, and very nice) and his dog.

Terry Pratchett and I met in February 1985, in a Chinese restaurant. I was a young journalist. He was a former journalist and Electricity Board PR, and a writer who had just published his second Discworld novel. I was the first journalist who had ever interviewed him.

I remember we made each other laugh a lot. We laughed at the same things. We became friends. It was easy.

In 1987 I wrote a book about Douglas Adams and the Hitchhiker's Guide to the Galaxy. By the end of it I had learned that I could write in a style I thought of as Classic English Humour. Douglas had science fiction tied up, Terry had fantasy, but nobody was writing funny horror. And an exchange in Marlowe's The Jew of Malta, combined with a late night viewing of The Omen and a love of Richmal Compton's immortal Just William stories, had put a story into my head, about a demonic baby-swap that goes wrong, in which the Antichrist grows up to be a nice kid, with a dog and a gang.

I wrote the first 5,000 words of William the Antichrist. It had a demon named Crawleigh. He drove a Citroen 2CV, and was ineffectual. Proper demons like Hastur and Ligur loathed him. It had a baby swap. I sent it to a few friends for feedback. Then my graphic novel Sandman happened, and it was almost a year later that the phone rang.

"It's Terry," said Terry. "'Ere. That thing you sent me. Are you doing anything with it?"

"Not really."

"Well, I think I know what happens next. Do you want to sell it to me? Or write it together?"

"Write it together," I said, because I was not stupid, and because that was the nearest I was ever going to get to Michaelangelo phoning to ask if I wanted to paint a ceiling with him.

Image caption Neil Gaiman and Terry Pratchett

Terry took the first 5,000 words and typed them into his word processor, and by the time he had finished they were the first 10,000 words. Terry had borrowed all the things about me that he thought were amusing, like my tendency back then to wear sunglasses even when it wasn't sunny, and given them, along with a vintage Bentley, to Crawleigh, who had now become Crowley. The Satanic Nurses were Satanic Nuns.

The book was under way.

We wrote the first draft in about nine weeks. Nine weeks of gloriously long phone calls, in which we would read each other what we'd written, and try to make the other one laugh. We'd plot, delightedly, and then hurry off the phone, determined to get to the next good bit before the other one could. We'd rewrite each other, footnote each other's pages, sometimes even footnote each other's footnotes.

We would throw characters in, hand them off when we got stuck. We finished the book and decided we would only tell people a little about the writing process - we would tell them that Agnes Nutter was Terry's, and the Four Horsemen (and the Other Four Motorcyclists) were mine.

The second draft took about four months, as we took what we'd done and did our very best to make it look like we knew what had been doing all along. Pepper became a girl, and so did War. I went to stay with Terry at the end of the book, to patch it all together and make sure it worked, and slept in his spare room. The window was open, and there was a dovecote nearby. When he woke me that morning, the air of the bedroom was filled with fluttering white doves. I assumed this always happened in the Pratchett household, but he said it was only me.

All that remained was to find a title for the book we'd written. I suggested Good Omens, Terry liked The Nice and Accurate Prophecies of Agnes Nutter, Witch. We compromised, or rather, we collaborated, and we had a title and a subtitle.

More about Neil Gaiman

Author of bestselling novels including Neverwhere, American Gods, and The Ocean At The End Of The Lane; also wrote the graphic novel series, The Sandman

Books for children include Coraline and The Graveyard Book

Has also written episodes for Doctor Who, including "The Doctor's Wife"

People still ask us who wrote what, and, mostly, we've forgotten. We tried to make sure that by the end we'd each written all of the major characters (I handed over the Four Horsemen to Terry when they got to the air force base, and I took the Them). There were bits we were both convinced we had written, and bits we were both convinced that we hadn't.

And then, 25 years ago, the book was published, and something odd happened. It took on a life of its own, in the UK, in the US, all around the world. People would bring copies of Good Omens to signings, and the books were either swollen as if they had been dropped in the bath during an exciting bit, or so well read that the pages were now trying to escape.

The only brand-new copies we would ever see were gifts, or replacements for copies borrowed by friends and never returned. "It's my sixth copy. The others never came back," people would tell us, with a mixture of pride and resignation. We would write HAVE A NICE DOOMSDAY on their books. Or one of us would write BURN THIS BOOK and the other, when he got it, APPLY HOLY MATCH HERE.

Our story of an 11-year-old Antichrist, of an angel and a demon, a witchfinder and a witch, had found its audience. It began to appear on lists of best-loved novels. People wrote fan fiction (mostly about Crowley and Aziraphale), people dressed up as the characters (mostly Crowley and Aziraphale), people asked us when we were going to write a sequel, one featuring Crowley and Aziraphale.

The Good Omens film never quite happened, although Terry Gilliam worked hard to make it happen, and Johnny Depp would have made a fine Crowley. But some things became inevitable. And after last year's triumphant adaptation by Dirk Maggs and Heather Larmour of my novel Neverwhere, a Good Omens radio series became inevitable.

Have a nice doomsday.

The Omen

Image copyright ALAMY

Includes plot spoilers

It's 6 June at 0600. One baby is delivered stillborn. Another is delivered as his mother dies. The American diplomat father of the stillborn baby is persuaded by a priest to swap babies. He does not tell his wife.

All is well until the child - Damien - turns five. A series of sinister deaths follow.

Enter a spooky nanny with an even spookier black dog to "guard" Damien while his father is away.

Enter priest spouting prophesies about Damien ruling the world.

Cue the Book of Revelation and its apocalyptic visions.

Good Omens will be broadcast on Radio 4 between 22 and 27 December at 23:00 GMT. You can catch up via the BBC iPlayer

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.