Soldiers in January 1980 in Gardez, Afghanistan, a month after the Soviet Union invaded. A newly published cable suggests a reason for the invasion was a fear that Afghanistan might switch loyalties to the West.CreditCreditAlain Mingam/Gamma-Rapho, via Getty Images

WASHINGTON — One day in October 1979, an American diplomat named Archer K. Blood arrived at Afghanistan’s government headquarters, summoned by the new president, whose ousted predecessor had just been smothered to death with a pillow.

While the Kabul government was a client of the Soviet Union, the new president, Hafizullah Amin, had something else in mind. “I think he wants an improvement in U.S.-Afghan relations,” Mr. Blood wrote in a cable back to Washington. It was possible, he added, that Mr. Amin wanted “a long-range hedge against over-dependence on the Soviet Union.”

Mr. Blood’s newly published cable sheds light on what really drove the Soviet Union to invade Afghanistan only two months after his meeting with Mr. Amin. Spoiler alert: It was not because of terrorism, as claimed this month by President Trump, who said the Soviets were right to invade. Among the real motivations, the cable and other documents suggest, was a fear that Afghanistan might switch loyalties to the West.

“This was a key moment that raised the Soviet sense of threat,” said Thomas S. Blanton, the director of the National Security Archive, a research organization at George Washington University that recently obtained the cable through the Freedom of Information Act and posted it online on Tuesday. “It’s a fascinating case study of the necessity in all of these international affairs of putting yourself in the other guy’s place — what does it look like over there?”

The origins of the Soviet invasion offer lessons for a history-challenged Mr. Trump as he negotiates an end to the United States’ own war in Afghanistan, now 17 years old. An American envoy reported Monday that he has reached a draft framework for peace with the Taliban.

A hardscrabble land of breathtaking beauty and unimaginable brutality, torn by religious, ethnic and tribal divisions and stuck in a virtually medieval reality, Afghanistan has been at the center of geopolitical contests for centuries — and high on the American priority list since the Soviet invasion of December 1979.

That intervention ruptured relations between the superpowers as President Jimmy Carter suspended grain sales to the Soviet Union and boycotted the 1980 Olympic Games in Moscow. He also began a military buildup later accelerated by President Ronald Reagan, and American support for the mujahedeen rebels helped drive the bloodied Soviets out in 1989.

Some of the United States’ allies in that war, however, later switched sides, and Afghanistan became a haven for Osama bin Laden’s Al Qaeda. After the Sept. 11, 2001, attacks in New York, Washington and Pennsylvania, President George W. Bush sent forces to topple the Taliban government. His successor, President Barack Obama, temporarily sent even more troops.

But Mr. Trump argues that it is time to leave. During a cabinet meeting in early January where he discussed plans to withdraw half of the 14,000 American troops in Afghanistan, Mr. Trump said other countries should pick up the slack, including Russia.

Video

Afghanistan is America’s longest war — 17 years. That’s longer than World War I, World War II and the Korean War combined.

“The reason Russia was in Afghanistan was because terrorists were going into Russia,” he said of the 1979 invasion. “They were right to be there. The problem is it was a tough fight.”

No other American president has endorsed the Soviet aggression, and Mr. Trump’s fanciful version of history drew widespread mockery. But Mr. Blanton, who researched the issue with Svetlana Savranskaya, a senior analyst at the archive, said initial American interpretations of Soviet motivations were wrong, as well.

In a memo to Mr. Carter two days after the invasion, his national security adviser, Zbigniew Brzezinski, suggested it stemmed from “the age-long dream of Moscow to have direct access to the Indian Ocean” — although it would require further territorial claims by Moscow even if it did conquer landlocked Afghanistan.

The more conventional understanding was the desire by the Kremlin to prop up a fellow Communist state.

“If they lost Afghanistan to the West, they would be losing more than a strategically placed country on their borders,” said Michael Dobbs, whose book “Down With Big Brother” chronicled the last years of the Soviet Union. “They would effectively be acknowledging that history can be reversed, setting the stage for the disintegration of the entire empire.”

Mr. Blood’s cable suggests that Mr. Amin was open to a realignment that stirred fears in Moscow of another Egypt, which broke from the Soviet orbit in 1972. During their 40-minute meeting on Oct. 27, 1979, Mr. Amin, speaking English, said he wanted to draw closer to the United States, where he once studied.

“He then went on, with considerable eloquence, to stress his personal commitment to improving U.S.-Afghan relations, expressing his affection for the U.S. acquired during his residence in our country,” Mr. Blood wrote.

Mr. Amin denied that the Soviets called the shots. “He was declaiming how he could never sacrifice Afghan independence to any foreign demands, including from the Soviets,” Mr. Blood wrote.

The American diplomat came away with a positive view of Mr. Amin. “The man is impressive,” Mr. Blood wrote. “His survival to date is by itself impressive, as is the air of quiet self-confidence he exudes. Clearly, he is aware of the mortality rate of Afghan leaders; several times he said ‘even if I am killed tomorrow.’ He masks his ruthlessness and toughness quite well by his soft-spoken manner.”

Still, Mr. Blood was cautious, recommending no seismic shift immediately while the United States assessed Mr. Amin’s staying power. In Moscow, however, the meeting was noticed with alarm.

“We have been receiving information about Amin’s behind-the-scenes activities which might mean his political reorientation to the West,” Yuri V. Andropov, the K.G.B. chief, told the Soviet leader Leonid I. Brezhnev in a handwritten memo in December 1979. “He keeps his contacts with the American chargé d’affaires secret from us.”

Image

Mujahedeen fighters watching for Russian convoys in February 1980 in Herat, Afghanistan. American support for the fighters helped drive the Soviets out in 1989.CreditJacques Langevin/Associated Press

The Andropov memo was made public in 1995 when Anatoly F. Dobrynin, the longtime ambassador to the United States, went to the Russian archives and transcribed documents for a project by the Norwegian Nobel Institute. At a meeting on Dec. 8, 1979 — also transcribed by Mr. Dobrynin — Mr. Andropov and Dmitri F. Ustinov, the defense minister, cited the dangers of American missiles being deployed in Afghanistan.

“The picture Andropov is painting in early December is that if Amin did a flip, it would totally change the geopolitical balance in South Asia,” Mr. Blanton said. “It would be as if Mexico became a base for Soviet short-range missiles. How would we feel?”

Mr. Blood’s cable has been mentioned publicly before. Henry S. Bradsher, a longtime foreign correspondent who wrote the book “Afghanistan and the Soviet Union,” published in 1983, obtained a copy of a version that had been sent to the United States Embassy in Iran, was shredded during the hostage crisis and was later pieced back together.

In a 1989 oral history, Mr. Blood kept quiet about the possible change in the relationship. Instead, he focused on an episode earlier in the year when the United States ambassador to Afghanistan, Adolph “Spike” Dubs, was kidnapped in Kabul and killed during a rescue attempt.

“Washington asked me to seek an appointment with Hafizullah Amin who was the president and the leader,” Mr. Blood, who died in 2004, said in the oral history. “About the only thing they wanted to tell him was that he couldn’t expect any resumption of aid until he could satisfy us about their role in Spike’s death.”

Rodric Braithwaite, the last British ambassador to the Soviet Union and the author of “Afgantsy: The Russians in Afghanistan, 1979-89,” said on Monday that it had long been known that the Kremlin worried that Mr. Amin was turning to the United States, but said Soviet leaders had multiple motives for the invasion.

“It’s difficult to weight all the considerations,” he said, “but the Russians’ main concern was to ensure that a country on their vulnerable southern border, which they had cultivated for decades, didn’t become hostile.”

The Kremlin was also angered that Mr. Amin had not only toppled President Noor Muhammad Taraki, who had its backing, but had him killed. On Dec. 12, 1979, the Politburo approved a miliary intervention with no debate as Mr. Brezhnev and the others signed a handwritten decision memo titled “On the Situation in ‘A.’”

The Soviets tried to kill Mr. Amin only to botch it. The day after the “A” memo was signed, a K.G.B. operative slipped poison into his Coca-Cola, but the carbonation diluted the toxic agent. A couple of weeks later, the K.G.B. poisoned his food, but the Soviet Embassy in Afghanistan, unaware of the plot, sent doctors to save him. Only when thousands of Soviet troops poured into Afghanistan did they finally dispatch the troublesome leader, this time during crossfire.

The invasion was intended to be a quick operation, as in Hungary in 1956 and Czechoslovakia in 1968. But resistance to the Soviets was fierce and unrelenting. The realignment Mr. Blood broached took place as a result, with the United States coming to the aid of the Afghan rebels. It was, however, a realignment that would not last.

Follow Peter Baker on Twitter: @peterbakernyt.

A version of this article appears in print on , on Page A5 of the New York edition with the headline: Lesson on the Soviets and Afghanistan, Laid Out in a Cable. Order Reprints | Today’s Paper | Subscribe