Dr. Montgomery displays two photographs of himself taken in 1943. (Cliff Owen/AP)

Benny Goodman and his band serenaded the guests as Hugh Montgomery slipped into the powder room in the Moscow residence of the U.S. ambassador to the Soviet Union. The date was July 4, 1962 — Independence Day — and the musical entertainment had attracted Soviet Premier Nikita Khrushchev to the ambassador’s festivities.

Dr. Montgomery, a CIA officer posing as a diplomat, was there to receive a cache of documents from Oleg Penkovsky, a Soviet intelligence officer widely considered the most valuable double agent working for the West during the Cold War. Penkovsky was to leave the material in the ambassador’s toilet tank, where Dr. Montgomery would furtively collect it.

What transpired was “more ‘The Pink Panther’ than John le Carré,” a writer for U.S. News and World Report quipped decades later. To reach the tank, suspended up high, Dr. Montgomery first stood on the toilet seat, which cracked under his weight. He then climbed atop the sink, causing it to detach from the wall. He retrieved the documents — but only after soaking his sleeve in the toilet-tank water. Taking his wife by his wet arm, he escaped unnoticed.

Dr. Montgomery, who had darted behind German lines with the Office of Strategic Services during World War II and became one of the most admired CIA officers of his generation, died April 6 at his home in McLean, Va. He was 93 and had congestive heart failure and other ailments, said his son, Hugh Montgomery Jr. Dr. Montgomery had retired at 90, after more than six decades in intelligence.

“He really was the last link to the OSS and the very beginning of the American intelligence capability,” former CIA director Leon E. Panetta said in an interview. “He was every bit a symbol of the kind of officer that we were proud to have in the CIA.”

Hugh Montgomery was born in Springfield, Mass., on Nov. 29, 1923. His father ran a firm that manufactured wire products. His mother, a linguist, inspired her son’s interest in languages. Dr. Montgomery brought to the CIA proficiency in eight languages and working knowledge of more.

He was studying Romance languages and literature at Harvard University when he joined the Army around the time of the Japanese attack on Pearl Harbor in 1941. On D-Day, he parachuted into Normandy, France, with the 82nd Airborne. He was wounded in action, leaving him with a lifelong limp.

He was soon recruited to the OSS — a wartime predecessor of the CIA — and in particular to its counterintelligence detachment, called X-2, although he did not know the secretive operation’s name until much later.

Panetta described Dr. Montgomery as having a “calmness” that served him well in the field. He repeatedly went behind enemy lines, searching for German nuclear physicists and Americans POWs and on one occasion commandeering an enemy intelligence radio outpost.

In Germany in spring 1945, Dr. Montgomery said that he and his colleagues discovered a compound surrounded by barbed wire and emanating a “ghastly smell.” They had arrived at the Buchenwald concentration camp, not yet officially liberated by the Americans, but no longer under firm Nazi control.

“The surviving inmates begged us to leave the German guards to their hands, which we did,” Dr. Montgomery recalled in a speech in 2015, when he received the William J. Donovan Award, named for the founder of the OSS, bestowed by the OSS Society.

He returned to the United States after the war and resumed his studies at Harvard, where he received a bachelor’s degree in 1947, a master’s degree in 1948 and a doctorate in 1952. He “epitomized what was described as an ideal OSS candidate,” Charles Pinck, president of the OSS Society, wrote in an email, “a Harvard Ph.D. who could handle himself in a bar fight.”

Dr. Montgomery joined the CIA in 1952. In Berlin, he participated in operations involving the Berlin tunnel, burrowed by the CIA and British MI6 to tap Soviet communication lines. He later served as deputy station chief in Moscow, where he was a handler for Penkovsky, who was executed by the Soviets in 1963. Dr. Montgomery also served as station chief in Vienna and Rome.

During the Reagan administration, he left the CIA to serve as director of the State Department’s Bureau of Intelligence and Research and later as alternate U.S. representative to the United Nations for special political affairs, holding the rank of ambassador.

Under CIA Director Robert M. Gates, Dr. Montgomery oversaw all foreign intelligence relationships. He later helped document and preserve the history of U.S. intelligence, both within the CIA and as chairman of the OSS Society. His awards included the Distinguished Career Intelligence Medal.

Dr. Montgomery’s wife of 66 years, the former Annemarie Janak, died in 2015. Survivors include two children, Hugh Montgomery Jr. of Batavia, Ohio, and Maria Montgomery of Columbia, Md.

In an interview, Gates describes Dr. Montgomery as “a man of extraordinary integrity and character” — and also as one who would not be out of place “in any one of a number of spy novels.” His escapade at the Soviet Embassy in 1962 ended with a surprise for the U.S. ambassador — and a timeless tale for the CIA.

“At the next embassy staff meeting,” then-CIA Director John O. Brennan recounted at the Donovan Award ceremony, the ambassador demanded the name of the Russian “who trashed his wife’s powder room.”