A convoy of Soviet troops waves to crowds during its withdrawal from Afghanistan on May 15, 1988.Richard Ellis / Reuters

When the Soviet Union shocked the world by sending troops into Afghanistan 40 years ago this December, few Western observers guessed it was more thanks to accident and blunder than a conscious decision to invade. Eager to foment a quick coup that would prop up a flailing fellow Communist government and prevent U.S. influence from filling a geopolitical vacuum, the Soviet leaders believed they were acting with surgical precision. They failed to realize that sending in troops, which they saw as a mere precaution, would be seen inside Afghanistan as taking one side in a burgeoning civil war—and by others as a land grab by a ruthless superpower.

Compared with Donald Trump’s bizarre ramblings on Wednesday, however, the Kremlin’s Marxism-colored delusions seem minor. His mischaracterization of the Soviet war contained no single scrap of truth, let alone logic. It was issued to justify an Afghanistan policy that risks undermining the very few gains almost two decades of Western-led effort have produced by ignoring lessons from both the Soviet and NATO-led campaigns.

“Russia used to be the Soviet Union,” Trump declared in televised remarks at the White House following a Cabinet meeting. (Actually, it was only the largest of 15 Soviet republics.) “Afghanistan made it Russia because they went bankrupt fighting in Afghanistan.”

“The reason Russia was in Afghanistan was because terrorists were going into Russia,” he added, before becoming the first transatlantic leader to endorse the Soviet invasion: “They were right to be there. The problem is, it was a tough fight. And literally, they went bankrupt; they went into being called Russia again, as opposed to the Soviet Union. You know, a lot of these places you’re reading about now are no longer part of Russia because of Afghanistan.”

In fact, terrorism had nothing to do with Moscow’s incursion. (Trump may have been confusing the rationale for another invasion—in Chechnya.) The war in Afghanistan was prompted more than anything by displeasure with the country’s then-president, Hafizullah Amin. Although he led Afghanistan’s Soviet-backed Communist party, he had angered the Kremlin by assassinating his predecessor, Mohammed Taraki, a rival Communist. Moscow blamed Amin’s ruthlessness for a wave of rebellion in the countryside that threatened the government. By eliminating him, the Kremlin reasoned, a coup d’état would save the Communist regime that kept the Soviet Union’s southern neighbor within Moscow’s sphere of influence.

So in December 1979, a cook who was a KGB agent working in one of Afghanistan’s presidential palaces administered poison to a meal he was preparing for Amin. But when he dissolved the poison in a glass of the president’s favorite drink, Coca-Cola, its bubbles rendered the concoction harmless. A second poisoning two weeks later would have succeeded if doctors sent by the Soviet embassy in Kabul—which was uninformed of the KGB’s plans—hadn’t resuscitated Amin. By then, Red Army troops were invading, and the president was killed soon after, when Soviet special-forces units stormed his palace.

The bungling would have been comical were the results not so tragic. The Kremlin’s surprise incursion turned into a grinding campaign against local insurgents made worse by dismal Soviet military discipline, vicious hazing, and miserable rations, which forced soldiers to raid local farms and stores—and which turned Afghan hearts and minds against Moscow.

Despite grievous mistakes in planning and execution, however, the Soviet war in Afghanistan was no unmitigated failure. Until Washington provided the rebel mujahideen with Stinger surface-to-air missiles in 1986, Moscow had the upper hand. The rub for the U.S.S.R. was that soon after the reforming Mikhail Gorbachev came to power in 1985—but before the introduction of the Stinger missiles turned the conflict’s tide—he had already promised to withdraw Soviet troops. Nevertheless, they remained another four years, piling up the military and civilian casualties and helping generate growing numbers of extremist militants, to which the United States did much to contribute by arming and financing mujahideen groups that attracted foreign fighters.

But the operative falsehood among Trump’s lies on Wednesday was that the war in Afghanistan triggered the Soviet collapse. In fact, the end of communism had to do with the corruption of a bloated command economy, starved by a drop in oil prices and finally undone by the chaos following Gorbachev’s decision to relax the Kremlin’s control. The war in Afghanistan played a symbolic role, projecting an image at home and abroad of a failing empire unable to deal with a handful of bedraggled partisans in a remote part of its southern frontier.

In the decades following the Soviet withdrawal in February 1989—30 years ago next month—Russians slowly began coming to terms with the defeat. When I was researching a 2009 book about the Soviet war, I found enough time had passed for many veterans to be able to critically reflect on what they saw as a tragedy. Among them, Valery Kurilov—an elite special-forces officer who had taken part in the raid that killed Amin in 1979—told me he wasn’t surprised that the Taliban and al-Qaeda found fertile ground in the 1990s. “Why should Afghans share our values and respect us? What values are we even talking about?” he said. “We invaded their country, robbed and killed them, then simply packed up and left.”

Such views began changing around 2008, when Russian President Vladimir Putin began his confrontation with the West in earnest, and the war came to be seen through the prism of Soviet nostalgia and renewed competition with the United States. Taking their cue from the Kremlin, veterans began blaming the CIA for providing the bullets that killed their comrades.

Still, the failure in Afghanistan hangs over Putin’s foreign adventures. In Ukraine’s conflict as well as in Syria’s, the Kremlin’s overarching goal is to obstruct Washington and its allies rather than to commit to any costly final outcomes: It’s about tactics, not strategy, with minimal Russian risk and the ability to pull out at a moment’s notice and declare victory. That’s also happening again in Afghanistan, where Russia is enabling the Taliban under the guise of brokering peace talks between the militant group and the government—because Putin’s chief aim is to stymie NATO and the United States by fueling instability rather than to enable a political settlement.

That’s dangerous for Moscow. On top of the security threat extremist militants pose to Russia’s southern flank and its Central Asian neighbors, most of the heroin fueling a Russian addiction epidemic comes from Afghanistan’s Taliban-controlled poppy fields. But Putin’s ultimate goal has never been advancing his country’s interests as much as consolidating his own power by posing as a restorer of Russian greatness.

The U.S. goal in Afghanistan should be the opposite of Moscow’s, requiring a commitment to long-term nation building in a country Washington helped ravage in the 1980s. Although the United States and NATO officially ended combat operations in 2014, American and allied troops are still helping hold the state together, conducting strikes on the Islamic State and the Taliban and training the Afghan military.

Far more needs to be done. Instead, Trump has ordered a withdrawal of some 7,000 troops, half of the currently deployed 14,000 troops. Among many others to have criticized the move, retired General Stanley McChrystal—a loud critic of former President Barack Obama—called Trump’s actions “immoral,” saying they have “basically traded away the biggest leverage point we have” in the country.

Trump’s bid for short-term political gain by fulfilling a campaign promise to his radicalized right-wing electoral base will help free Russia’s hand, boost the Taliban and the Islamic State, and put Afghanistan’s civilian population at greater risk, further threatening international security. The Soviets may have blundered into a civil war they never fully understood four decades ago. But however misguided they were in 1979, our current president’s rambling justifications are actually making them look relatively wise.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.