The recent diplomatic storm in a teacup over the NSA's monitoring of Angela Merkel's cellphone was a reminder that in matters of intelligence, national self-interest trumps every other card. Equally striking, though, was the evident resentment of the Germans and French over the Anglosphere's "five eyes" intelligence-sharing arrangement, from which they are excluded and which enables the U.S. agency to use its British counterpart to spy on American citizens without breaking any federal laws. Barack Obama and David Cameron don't need to spy on each other because their agencies pool all significant intelligence anyway.

At the heart of Calder Walton's "Empire of Secrets: British Intelligence, the Cold War, and the Twilight of Empire," an important and highly original account of postwar British intelligence, is a history of the Anglo-American "special relationship." Dean Acheson was only partly right in 1962 when he declared that Great Britain had lost an empire but not yet found a role. Britain had lost an empire, but she had also become the indispensable partner of the U.S. in the Cold War. Now that the British government has opened many, though not all, of its secret-service archives, scholars such as Mr. Walton have discovered how far that new role depended on intelligence.

"Empire of Secrets" covers the period from World War II, when Britain had the largest empire in history, to the 1967 withdrawal from Aden, the country's last Middle Eastern stronghold, which they left, Mr. Walton writes, in "a shameful manner, handing power over to a homicidal Marxist regime." "Empire of Secrets" is the first book on the twilight of empire to be based on declassified intelligence records and includes detailed case studies of Palestine, Malaya and Africa, with a more general overview of imperial security during the first two decades of the Cold War.

There was nothing inevitable about the special relationship. At the end of World War II, Dwight Eisenhower personally congratulated the British intelligence services, which he felt had been "decisive" in the defeat off the Nazis. And the OSS, forerunner of the CIA, owed much to its British counterparts. As one OSS officer said: "The British taught us everything we knew but not everything they knew." Within a few months of peace in 1945, however, the relationship between the two intelligence communities had, in Mr. Walton's words, "almost completely broken down."

The reason was the Cold War, with its sudden shifting of allegiances provoking subversion, defections and panic. Almost overnight, Washington cut its intelligence links with the British, who were seen as vulnerable to Soviet penetration. The Americans also had a distaste for the culture of "gentlemen amateurs" that prevailed in the higher reaches of the British secret service. This was the world we all know from James Bond. Ian Fleming created an archetype that still fascinates, and he himself exemplified Bond's milieu at its worst: snobbery, misogyny, anti-Semitism and an overweening sense of racial and cultural superiority.
Mr. Walton offers a partial corrective to this abiding 007 stereotype. The British need to keep up with and reassure their American counterparts in addressing the Soviet threat quickly led to a more professional postwar intelligence service. This required "positive vetting," meaning active investigation of every official with access to intelligence—despite the postwar Labour government's protestations of hostility to a "police state." It also meant a vast extension of surveillance across the empire, especially as decolonization gathered speed.

The more serious reason for American frustration was that it took the British some time after the war to refocus on the new Soviet threat. Mr. Walton shows that London's top priority was terrorism: specifically, the Zionists hostile to the British Mandate regime in Palestine, the Irgun and the "Stern Gang." Bizarre as it may sound today, there was justification for the fears of MI5, which in 1946 warned that every senior official from the prime minister downward was a target. In 1947, a young Irgun operative, Betty Knout, succeeded in planting a large bomb inside the Colonial Office in London. It failed to go off, but such audacious plots caused the British security services constant anxiety.

Members of the Stern Gang claimed to have come close to assassinating Ernest Bevin, the foreign secretary, and their explosives expert, the "Dynamite Man" Yaacov Eliav, invented a new device: the letter bomb. They targeted the entire cabinet, and, though none of the bombs got through in the end, the future Prime Minister Anthony Eden unwittingly carried one around with him in his briefcase for a whole day.
In Palestine itself the carnage caused by attacks such as the 1946 King David Hotel bombing provoked a draconian response from the British, which alienated the moderate Jewish population. The end of British rule was a shambles. When they left in May 1948, the chief secretary of the administration, Sir Henry Gurney, was asked to whom he would leave the keys to his office. "To nobody," he replied. "I shall leave them under the mat." As Mr. Walton notes: "Palestine was the intelligence war that Britain lost."
The British, however, learned from this debacle. In Malaya and Kenya, they defeated insurgencies and kept the postcolonial regimes within the Western camp during the Cold War—not without violence that occasionally degenerated into barbarism. Mr. Walton shows how success eluded the British when local intelligence officials failed to place human agents among their enemies: "Then as now, torture was the last refuge of the ineffectual." The same Sir Henry Gurney, who re-emerged as Malayan high commissioner, admitted privately that the British army was breaking the law "almost every day."

Intelligence, Mr. Walton shows, was crucial as the empire wound down. For example, close surveillance of two of the most radical African anti-colonial leaders, Kwame Nkrumah and Jomo Kenyatta of Ghana and Kenya, respectively, convinced MI5 that neither was likely to succumb to Soviet blandishments—thereby contradicting the received wisdom in Whitehall. By 1960, when Prime Minister Harold Macmillan spoke in South Africa of the "wind of change blowing through this continent," it had been accepted in Whitehall's intelligence agencies that there was little to fear from granting independence to Britain's African possessions but much from Soviet influence. The special relationship was in much better shape by the late 1960s, too, with the anti-colonialist Americans happy to benefit from Britain's imperial legacy. Mr. Walton concludes with the creation in 1974 of the main U.S. base in the Indian Ocean at Diego Garcia, where Britain first removed the inhabitants and then "allowed America to use the Chagos Islands effectively as its own colony."
Mr. Walton's study does an excellent job of elucidating the part played by British intelligence in decolonization. It is not a glorious chapter in British history; the best that can be said is that most other European imperial powers—the French, the Belgians, the Portuguese—did considerably worse.

An abiding image of the end of empire came after the Suez debacle in 1956. Abandoned by his American ally and forced to withdraw his troops from Egypt, Prime Minister Anthony Eden fled London to stay at the Jamaican home of Ian Fleming. His secretary, Evelyn Shuckburgh, confided to his diary: "The captain leaves the sinking ship which he had steered personally on to the rocks." Eden sought refuge with the creator of James Bond, just as the fiction of imperial power was confronted by the fact of post-imperial impotence. The irony is irresistible: The fantasy figure of James Bond is the last relic of the empire on which the sun never set.

Mr. Johnson is the editor of Standpoint magazine.