I wrote The Spy Who Came in from the Cold at the age of 30 under intense, unshared, personal stress, and in extreme privacy. As an intelligence officer in the guise of a junior diplomat at the British Embassy in Bonn, I was a secret to my colleagues, and much of the time to myself. I had written a couple of earlier novels, necessarily under a pseudonym, and my employing service had approved them before publication. After lengthy soul-searching, they had also approved The Spy Who Came in from the Cold. To this day, I don't know what I would have done if they hadn't.

As it was, they seem to have concluded, rightly if reluctantly, that the book was sheer fiction from start to finish, uninformed by personal experience, and that accordingly it constituted no breach of security. This was not, however, the view taken by the world's press, which with one voice decided that the book was not merely authentic but some kind of revelatory Message From The Other Side, leaving me with nothing to do but sit tight and watch, in a kind of frozen awe, as it climbed the bestseller list and stuck there, while pundit after pundit heralded it as the real thing.

And to my awe, add over time a kind of impotent anger.

Anger, because from the day my novel was published, I realised that now and forever more I was to be branded as the spy turned writer, rather than as a writer who, like scores of his kind, had done a stint in the secret world, and written about it.

But journalists of the time weren't having any of that. I was the British spy who had come out of the woodwork and told it how it really was, and anything I said to the contrary only enforced the myth. And since I was writing for a public hooked on Bond and desperate for the antidote, the myth stuck. Meanwhile, I was receiving the sort of attention writers dream of. My only problem was, I didn't believe my own publicity. I didn't like it even while I was subscribing to it, and there was in the most literal sense nothing I could say to stop the bandwagon, even if I'd wanted to. And I wasn't sure I did.

In the 60s – and right up to the present day – the identity of a member of the British Secret Services was and is, quite rightly, a state secret. To divulge it is a crime. The Services may choose to leak a name when it pleases them. They may showcase an intelligence baron or two to give us a glimpse of their omniscience and – wait for it – openness. But woe betide a leaky former member.

And anyway I had my own inhibitions. I had no quarrel with my former employers, quite the contrary. Presenting myself to the press in New York a few months after the novel had made its mark in the States, I dutifully if nervously mouthed my denials: no, no, I had never been in the spy business; no, it was just a bad dream – which of course it was.

The paradox was compounded when an American journalist with connections told me out of the corner of his mouth that the reigning chief of my Service had advised a former director of the CIA that I had been his serving officer, and that he had told nobody but his very large retinue of best friends, and that anyone in the room who was anyone knew I was lying.

Every interview I have faced in the 50 years since then seems designed to penetrate a truth that isn't there, and perhaps that's one reason why I have become allergic to the process.

❦

The Spy Who Came in from the Cold was the work of a wayward imagination brought to the end of its tether by political disgust and personal confusion. Fifty years on, I don't associate the book with anything that ever happened to me, save for one wordless encounter at London airport when a worn-out, middle-aged military kind of man in a stained raincoat slammed a handful of mixed foreign change on to the bar and in gritty Irish accents ordered himself as much Scotch as it would buy. In that moment, Alec Leamas was born. Or so my memory, not always a reliable informant, tells me.

Today I think of the novel as a not-very-well-disguised internal explosion after which my life would never be the same. It was not the first such explosion, or the last. And yes, yes, by the time I wrote it, I had been caught up in secret work off and on for a decade; a decade the more formative because I had the inherited guilt of being too young to fight in the second world war and – more importantly – of being the son of a war-profiteer, another secret I felt I had to keep to myself until he died.

But I was never a mastermind, or a mini-mind, and long before I even entered the secret world, I had an instinct towards fiction that made me a dubious fact-gatherer. I was never at personal risk in my secret work; I was frequently bored stiff by it. Had things been otherwise, my employers would not have allowed me to publish my novel, even if later they kicked themselves for doing so: but that was because they decided it was being taken too seriously by too many people; and because any suggestion that the British Secret Service would betray its own was deemed derogatory to its ethical principles, bad for recruitment, and accordingly Bad for Britain, a charge to which there is no effective answer.

The proof that the novel was not "authentic" – how many times did I have to repeat this? – had been delivered by the fact that it was published. Indeed, one former head of a department that had employed me has since gone on record to declare that my contribution was negligible, which I can well believe. Another described the novel as "the only bloody double-agent operation that ever worked" – not true, but fun. The trouble is, when professional spies go out of their way to make a definitive statement about one of their own, the public tends to believe the opposite: which puts us all back where we started, myself included.

And if the spies hadn't had me at that age, some equally luckless institution would have done, and after a couple of years I'd have been digging my way out.

❦

And the deep background of the novel? The sights, smells and voices that, 15 years after the end of the war, continued to infest every corner of divided Germany? The Berlin in which Leamas had his being was a paradigm of human folly and historical paradox. In the early 60s I had observed it mostly from the confines of the British Embassy in Bonn, and only occasionally in the raw. But I watched the Wall's progress from barbed wire to breeze block; I watched the ramparts of the cold war going up on the still-warm ashes of the hot one. And I had absolutely no sense of transition from the one war to the other, because in the secret world there barely was one. To the hard-liners of east and west the second world war was a distraction. Now it was over, they could get on with the real war that had started with the Bolshevik Revolution in 1917, and had been running under different flags and disguises ever since.

No wonder then if Alec Leamas found himself rubbing shoulders with some pretty unsavoury colleagues in the ranks of western intelligence. Former Nazis with attractive qualifications weren't just tolerated by the Allies; they were positively mollycoddled for their anti-communist credentials. Who was America's first choice to head West Germany's embryonic intelligence service? General Reinhard Gehlen, former chief of Hitler's Foreign Armies East (Russian theatre) where he had made himself a corner in the Soviet order of battle. Anticipating Germany's defeat, the General had assembled his files and his people, and at the first opportunity turned them over to the Americans, who accepted them with open arms. Recruited, Gehlen tactfully dropped the "General" and became Herr Doktor instead.

But where to house this precious asset and his crown jewels? The Americans decided to install Gehlen and his people in the cosy Bavarian village of Pullach, eight miles outside Munich and handy for their intelligence headquarters.

And whose handsome country estate, now vacant, did they select for the Herr Doktor? Martin Bormann was Hitler's most trusted confidant and private secretary. When the Führer established himself at his Eagle's Nest just up the road, his buddies scurried to set up house nearby. Gehlen and his people were settled in Bormann's villa, now the subject of a conservation order issued by the Bavarian government. Just a few years ago, in circumstances of extraordinary courtesy, one of the Bundesnachrichtendienst's [German intelligence service's] latter-day luminaries gave me a personal tour. I recommend the 1930s furniture in the conference room, and the Jugendstil statues in the gardens at the back. But the main attraction must surely be the great dark staircase winding into the cellars, and the fully furnished bunker, just like the Führer's, but smaller.

Was Alec Leamas a regular visitor to Pullach? He had no choice. Few secret operations into East Germany could take place without the connivance of the BND. And did Leamas, on his regular visits, perhaps come across the Herr Doktor's valued chief of counter intelligence, Heinz Felfe, formerly of the SS and Sicherheitsdienst [Nazi intelligence service]? He must have done. Felfe was a legendary operator. Had he not single-handedly unmasked a raft of Soviet spies?

Of course he had, and no wonder. When he was finally unmasked himself, he got 14 years for spying for Moscow, only to be traded for a bunch of hapless West Germans held there.

Did Leamas enjoy access to the ultra-secret "special material" obtained by Operation GOLD, the hugely costly quarter-mile-long, Anglo-American audio tunnel that tapped into Russian cables a couple of feet below the surface of a road in the Eastern Sector of Berlin? Before the first spade went into the ground, GOLD had been comprehensively blown by a Soviet agent named George Blake, the heroic ex-prisoner of North Korea and pride of the British Secret Service.

Yet to this day, many of GOLD's architects would have us believe that their operation was not merely an engineering triumph but an intelligence coup as well, on the questionable grounds that, so reluctant were the Russians to blow their agent, they let communications flow as usual.

Dissolve to a couple of years later and Kim Philby, once in line for chief, was also revealed as Moscow's man. No wonder poor Leamas needed that stiff Scotch at London airport. The Service that owned his unflinching allegiance was in a state of corporate rot that would take another generation to heal. Did he know that? I think deep down he did.

And I think I must have known it too, or I wouldn't have written Tinker Tailor Soldier Spy a few years down the line.

❦

The merit of The Spy Who Came in from the Cold, then – or its offence, depending where you stood – was not that it was authentic, but that it was credible. The bad dream turned out to be one that a lot of people in the world were sharing, since it asked the same old question that we are asking ourselves 50 years later: how far can we go in the rightful defence of our western values, without abandoning them along the way? My fictional chief of the British Service – I called him Control – had no doubt of the answer:

"I mean, you can't be less ruthless than the opposition simply because your government's policy is benevolent, can you now?"

Today, the same man, with better teeth and hair and a much smarter suit, can be heard explaining away the catastrophic illegal war in Iraq, or justifying medieval torture techniques as the preferred means of interrogation in the 21st century, or defending the inalienable right of closet psychopaths to bear semi-automatic weapons, and the use of unmanned drones as a risk-free method of assassinating one's perceived enemies and anybody who has the bad luck to be standing near them. Or, as a loyal servant of his corporation, assuring us that smoking is harmless to the health of the third world, and great banks are there to serve the public.

What have I learned over the last 50 years? Come to think of it, not much. Just that the morals of the secret world are very like our own.

• The 50th anniversary edition of The Spy Who Came in from the Cold, with "Fifty Years Later", John le Carré's introduction, will be published by Penguin at £25 on 1 August. © David Cornwell 2013.