Some books haunt the reader. Others haunt the writer. The Handmaid's Tale has done both.

The Handmaid's Tale has not been out of print since it was first published, back in 1985. It has sold millions of copies worldwide and has appeared in a bewildering number of translations and editions. It has become a sort of tag for those writing about shifts towards policies aimed at controlling women, and especially women's bodies and reproductive functions: "Like something out of The Handmaid's Tale" and "Here comes The Handmaid's Tale" have become familiar phrases. It has been expelled from high schools, and has inspired odd website blogs discussing its descriptions of the repression of women as if they were recipes. People – not only women – have sent me photographs of their bodies with phrases from The Handmaid's Tale tattooed on them, "Nolite te bastardes carborundorum" and "Are there any questions?" being the most frequent. The book has had several dramatic incarnations, a film (with screenplay by Harold Pinter and direction by Volker Schlöndorff) and an opera (by Poul Ruders) among them. Revellers dress up as Handmaids on Hallowe'en and also for protest marches – these two uses of its costumes mirroring its doubleness. Is it entertainment or dire political prophecy? Can it be both? I did not anticipate any of this when I was writing the book.

I began this book almost 30 years ago, in the spring of 1984, while living in West Berlin – still encircled, at that time, by the Berlin Wall. The book was not called The Handmaid's Tale at first – it was called Offred – but I note in my journal that its name changed on 3 January 1985, when almost 150 pages had been written.

That's about all I can note, however. In my journal there are the usual writerly whines, such as: "I am working my way back into writing after too long away – I lose my nerve, or think instead of the horrors of publication and what I will be accused of in reviews." There are entries concerning the weather; rain and thunder come in for special mentions. I chronicle the finding of puffballs, always a source of glee; dinner parties, with lists of those who attended and what was cooked; illnesses, my own and those of others; and the deaths of friends. There are books read, speeches given, trips made. There are page counts; I had a habit of writing down the pages completed as a way of urging myself on. But there are no reflections at all about the actual composition or subject matter of the book itself. Perhaps that was because I thought I knew where it was going, and felt no need to interrogate myself.

I recall that I was writing by hand, then transcribing with the aid of a typewriter, then scribbling on the typed pages, then giving these to a professional typist: personal computers were in their infancy in 1985. I see that I left Berlin in June 1984, returned to Canada, wrote through the fall, then spent four months in early 1985 in Tuscaloosa, Alabama, where I held an MFA chair. I finished the book there; the first person to read it was a fellow writer, Valerie Martin, who was also there at that time. I recall her saying: "I think you've got something here." She herself remembers more enthusiasm.

From 12 September 1984 to June 1985 all is blank in my journal – there is nothing at all set down, not even a puffball – though by my page-count entries it seems I was writing at white-hot speed. On 10 June there is a cryptic entry: "Finished editing Handmaid's Tale last week." The page proofs had been read by 19 August. The book appeared in Canada in the fall of 1985 to baffled and sometimes anxious reviews – could it happen here? – but there is no journal commentary on these by me. On 16 November I find another writerly whine: "I feel sucked hollow." To which I added: "But functional."

The book came out in the UK in February 1986, and in the United States at the same time. In the UK, which had had its Oliver Cromwell moment some centuries ago and was in no mood to repeat it, the reaction was along the lines of, "Jolly good yarn". In the US, however – and despite a dismissive review in the New York Times by Mary McCarthy – it was more likely to be: "How long have we got?"

Stories about the future always have a "what-if" premise, and The Handmaid's Tale has several. For instance: if you wanted to seize power in the US, abolish liberal democracy and set up a dictatorship, how would you go about it? What would be your cover story? It would not resemble any form of communism or socialism: those would be too unpopular. It might use the name of democracy as an excuse for abolishing liberal democracy: that's not out of the question, though I didn't consider it possible in 1985.

Nations never build apparently radical forms of government on foundations that aren't there already. Thus China replaced a state bureaucracy with a similar state bureaucracy under a different name, the USSR replaced the dreaded imperial secret police with an even more dreaded secret police, and so forth. The deep foundation of the US – so went my thinking – was not the comparatively recent 18th-century Enlightenment structures of the republic, with their talk of equality and their separation of church and state, but the heavy-handed theocracy of 17th-century Puritan New England, with its marked bias against women, which would need only the opportunity of a period of social chaos to reassert itself.

Like any theocracy, this one would select a few passages from the Bible to justify its actions, and it would lean heavily towards the Old Testament, not towards the New. Since ruling classes always make sure they get the best and rarest of desirable goods and services, and as it is one of the axioms of the novel that fertility in the industrialised west has come under threat, the rare and desirable would include fertile women – always on the human wish list, one way or another – and reproductive control. Who shall have babies, who shall claim and raise those babies, who shall be blamed if anything goes wrong with those babies? These are questions with which human beings have busied themselves for a long time.

There would be resistance to such a regime, and an underground, and even an underground railroad. In retrospect, and in view of 21st-century technologies available for spywork and social control, these seem a little too easy. Surely the Gilead command would have moved to eliminate the Quakers, as their 17th-century Puritan forebears had done.

I made a rule for myself: I would not include anything that human beings had not already done in some other place or time, or for which the technology did not already exist. I did not wish to be accused of dark, twisted inventions, or of misrepresenting the human potential for deplorable behaviour. The group-activated hangings, the tearing apart of human beings, the clothing specific to castes and classes, the forced childbearing and the appropriation of the results, the children stolen by regimes and placed for upbringing with high-ranking officials, the forbidding of literacy, the denial of property rights: all had precedents, and many were to be found not in other cultures and religions, but within western society, and within the "Christian" tradition, itself. (I enclose "Christian" in quotation marks, since I believe that much of the church's behaviour and doctrine during its two-millennia-long existence as a social and political organisation would have been abhorrent to the person after whom it is named.)

The Handmaid's Tale has often been called a "feminist dystopia", but that term is not strictly accurate. In a feminist dystopia pure and simple, all of the men would have greater rights than all of the women. It would be two-layered in structure: top layer men, bottom layer women. But Gilead is the usual kind of dictatorship: shaped like a pyramid, with the powerful of both sexes at the apex, the men generally outranking the women at the same level; then descending levels of power and status with men and women in each, all the way down to the bottom, where the unmarried men must serve in the ranks before being awarded an Econowife.

The Handmaids themselves are a pariah caste within the pyramid: treasured for what they may be able to provide – their fertility – but untouchables otherwise. To possess one is, however, a mark of high status, just as many slaves or a large retinue of servants always has been. Since the regime operates under the guise of a strict Puritanism, these women are not considered a harem, intended to provide delight as well as children. They are functional rather than decorative.

Three things that had long been of interest to me came together during the writing of the book. The first was my interest in dystopian literature, an interest that began with my adolescent reading of Orwell's Nineteen Eighty-Four, Huxley's Brave New World and Bradbury's Fahrenheit 451, and continued through my period of graduate work at Harvard in the early 1960s. (Once you've been intrigued by a literary form, you always have a secret yen to write an example of it yourself.) The second was my study of 17th and 18th-century America, again at Harvard, which was of particular interest to me since many of my own ancestors had lived in those times and in that place. The third was my fascination with dictatorships and how they function, not unusual in a person who was born in 1939, three months after the outbreak of the second world war.

Like the American revolution and the French revolution, like the three major dictatorships of the 20th century – I say "major" because there have been more, Cambodia and Romania among them – and like the New England Puritan regime before it, Gilead has utopian idealism flowing through its veins, coupled with a high-minded principle, its ever-present shadow, sublegal opportunism, and the propensity of the powerful to indulge in behind-the-scenes sensual delights forbidden to everyone else. But such locked-door escapades must remain hidden, for the regime floats as its raison d'être the notion that it is improving the conditions of life, both physical and moral; and like all such regimes, it depends on its true believers.

I was perhaps too optimistic to end the Handmaid's story with an outright failure. Even Nineteen Eighty-Four, that darkest of literary visions, does not end with a boot stamping on a human face for ever, or with a broken Winston Smith feeling a drunken love for Big Brother, but with an essay about the regime written in the past tense and in standard English. Similarly, I allowed my Handmaid a possible escape, via Maine and Canada; and I also permitted an epilogue, from the perspective of which both the Handmaid and the world she lived in have receded into history. When asked whether The Handmaid's Tale is about to "come true", I remind myself that there are two futures in the book, and that if the first one comes true, the second one may do so also.

The Handmaid's Tale is reissued this month by the Folio Society