Some years ago, I received a curious letter. It informed me that Poul Ruders, a young Danish composer, wanted to make my novel The Handmaid's Tale into an opera. I was surprised. Actually I thought: "This person is mad." I had a brief, nightmarish vision of a line of high-kicking Handmaids revealing their beige, utilitarian undergarments while singing some variation of The Anvil Chorus. But since I was travelling to Denmark around that time, I agreed to meet with Poul Ruders and hear his case.

The meeting took place in Copenhagen, on a red velvet banquette in - I believe - the lobby of the Hotel Angleterre. Ruders was all a composer should be: fervent, wild-eyed, but with the single-minded focus of a dentist's drill. "As soon as I read this book, I saw it as an opera," he said.

He'd been given a commission by the Royal Danish Opera Company for their first new opera in 34 years. This was a great honour for him, and also a great chance, but he said that he wanted to do something he found relevant. He wanted to do The Handmaid's Tale and nothing but The Handmaid's Tale, and if he couldn't do The Handmaid's Tale, he wouldn't do any opera at all. This was so much like Colette saying that if she couldn't have too many truffles she would rather do without truffles entirely that I had to respect it. I said yes.

The first hurdle was the contract. Nobody knew how to do this, as there weren't many late-20th-century-precedents for operas based on novels by living writers. Then there was the Danish and/or lawyerly cast of mind, an introspective one given to second thoughts, as in Hamlet. ("Whether 'tis prudenter in the contract to offer/ The perks and carrots of outrageous royalties/ Or to strike pen throughout a sea of clauses/ And screw the writer blind?") But with the help of various agents we managed to cobble something together. I forget who got the T-shirt rights, but it wasn't me.

The Handmaid's Tale is a dystopia set in the future, and as such it owes debts to Orwell's 1984, Huxley's Brave New World, and the tradition in general - a tradition that can be traced back to Plato's Republic, through Sir Thomas More's Utopia and the horse's paradise of Swift's Gulliver's Travels, and then through the many literary utopias and dystopias of the 19th and early 20th centuries. In it, a totalitarian dictatorship has appeared in the US, now called the Republic of Gilead. It has emerged during a period of disruption: in such times, people are likely to trade in their rights in favour of militarist governments that claim to be able to guarantee their safety.

Once in power, such governments tend to go for absolute power and, like all absolute power, this power corrupts. Such dictatorships gain initial acceptance by justifying their actions in the name of their subjects' most cherished beliefs. Thus the Republic of Gilead is not a Communist state or a monarchy: neither would get a toehold in the US. Instead it claims to be religious, and bases some of its more arcane practices on the literal interpretation of certain passages in the early books of the Bible.

It is an axiom of most dictatorships that they try to control sexuality, both male and female, and that they suppress most men, but all women; and so it is in Gilead. Dictatorships are hierarchical - the bunch at the top gets the most goodies - and so the leaders of Gilead are allotted the fertile females, now scarce in that area. They justify this with reference to Jacob and his two wives, Rachel and Leah, and their two handmaids, who had no right to their own children. "Solomon had 300 wives and 700 porcupines," the internet claims a child wrote in a Bible test. Porcupines or concubines, the Patriarchs and Biblical Kings were not what you'd call monogamous.

"What inspired The Handmaid's Tale?" I've often been asked. General observation, I might have said. Poking my nose into books. Reading newspapers. World history. One of my rules was that I couldn't put anything into the novel that human beings hadn't actually done.

I began the actual writing in west Berlin, in the spring of 1984. In five years the Wall would topple and the Soviet Union would disintegrate, but I had no way of knowing that. I visited east Berlin at the time, as well as Poland and Czechoslovakia. I'd followed events in Romania, where women were forced by the Ceausescu regime to have babies, and also in China, where they were forced not to. I'd been to Iran, and traced the advent of the repression of women under the Ayatollahs.

Just as importantly, I was born in 1939, at the outbreak of the second world war, so I've always taken an interest in the Nazis, and the USSR under Stalin. I read Churchill's memoirs when they came out, and Orwell's 1984 and Koestler's Darkness At Noon soon after they were published. As a college student, I was a volunteer worker with immigrants wishing to improve their English, and my charge was a woman doctor who'd escaped from Czechoslovakia. She was a wreck. I got an earful. On the other hand, I lived through the McCarthy years. They were no human-rights picnic either.

At Harvard Graduate School in the 1960s, I studied American Literature and Civilisation, as part of English Literature. I found Puritan New England fascinating, especially since these folks were my ancestors. Far from being the seekers after freedom often depicted, the Puritans were a repressive lot: their preoccupation with the state of their souls did not save them from expelling dissenters and hanging Quakers.

I took a particular interest in the Salem witchcraft trials. What sorts of conditions produce a group mentality that so blatantly violates justice and defies common sense, in the name of God and righteousness? What sorts of people benefit from egging such things on? I've always remembered the words of one New England divine, who preached a sermon of repentance after they'd all realised how badly they'd been bamboozled: "The Devil was indeed among us, but not in the form we thought." It's no accident that The Handmaid's Tale is set in Massachusetts.

The inclination towards tyranny, the wielding of absolute power by the few over the many, knows no ideological boundaries and is not confined to one time or space. I never trust anyone who says: "It can't happen here." Otherwise ethical people will commit the most serious injuries as long as they believe they are doing their "duty" - committing these injuries in a good cause. Lenin was not alone in believing that the end justifies the means: lots of people believe it, or act as if they do. It takes bravery of a different sort to maintain that the means defines the end: risk it during a time of high group stress and you're likely to be called naive, or a traitor.

Since its publication in 1985 The Handmaid's Tale has been translated into 35 languages. It was made into a film, starring Natasha Richardson, with a screenplay by Harold Pinter; it has been widely taught (as well as banned) in the US and Canada; it has appeared in A-level exams in England and as a set text on the French syllabus; it even has its own cribs devoted to it: The Handmaid's Tale for Dummies, you might say.

And now there was to be an opera. The librettist, Paul Bentley, had done his task; the music had been created; the premiere would take place in March 2000. I flew to Copenhagen for this. I was quite anxious: it's nerve-wracking to see your work transposed into another artistic medium, and opera as a form is notoriously risky. When it succeeds, it tears your heart out, but when it fails, it can fail grotesquely.

Everything has to work well, and work together: the music, the singing, the acting, the sets, the lighting. I was aware of the problems the creators of the opera must have faced. The novel has much internal monologue: how would they handle that? How to convey the back-story to the plot? Would the costumes look not strange and ominous, but merely silly?

The night of the premiere was dark and stormy. Rumour had it that the English director Phyllida Lloyd had been brought over to pull the production together; would she be able to do it? I'd heard, too, that the man playing the Commander had advanced cancer but was determined to sing. Would there be a medical incident on stage?

Then, too, the revolving set had been a challenge: singers had got dizzy and had fallen off. Would dozens of Handmaids whizz into the orchestra pit? I bit my fingers, as I do when tense. Bleeding from every cuticle, I set out for the opera house. The last thing I wanted was for the production to go down in flames, which would mean no more new operas in Denmark for another 34 years.

The opening scene-setter, in which porn shots alternated with exploding architecture such as the White House and the Statue of Liberty, was shocking even in the year 2000, when it seemed like fiction. Soon we were in thrall, or at least I was. What were the Danes making of all this, I wondered.

The Danes are not given to leaping to their feet, shouting "Bravo!" and hurling bouquets. Instead they stamp their feet, where no one can see them doing it. At the final curtain, after every driplet of emotion had been wrung from us, the foot-stamping was deafening. At the cast party afterwards, euphoria competed with hysteria, and also with relief: against the odds, it had all come together. They'd done it. I got a bit weepy.

Three years later - after 9/11, after the coming of rightwing religious ideology to the White House, and, most importantly, after the erosion of Constitutional rights of many kinds - this piece seems eerily prescient. In The Handmaid's Tale, the eye from the American dollar bill is used as a logo by the Gilead secret police, who control people through credit card information. It's the same eye just adopted by the Homeland Security folks, who can now - yes - control people through credit card information. That's what biologists would call "convergence".

The Handmaid's Tale is fiction. But what kind of fiction? To quote Yevgeny Zamyatin: "We need the most ultimate, the most fearsome, the most fearless 'Why?' and 'What next?'" Offred of The Handmaid's Tale is a distant sister to the heroine of Zamyatin's 1920s dystopia, We: "I do not want anyone to want for me - I want to want for myself."

© Margaret Atwood

· Margaret Atwood is the author of 10 novels. Her 11th, Oryx and Crake , will be published by Bloomsbury in May. The British premiere of The Handmaid's Tale, by Poul Ruders, will be performed by English National Opera at the Coliseum, London WC2, on April 3. Box office: 020-7632 8300.