Editor's Note: (Peter Bergen is CNN's national security analyst, a vice president at New America, and a professor of practice at Arizona State University. Bergen is the author of "The Cost of Chaos: The Trump Administration and the World." The views expressed in this commentary are his own. View more opinion on CNN.)
(CNN) Russian President Vladimir Putin had a plan to seize Ukraine quickly. Those plans dissolved from the first days of the Russians' invasion with their failure to capture Kyiv.
Putin's problems have only deepened in recent days with the surging Ukrainian counteroffensive that has seized key pockets of Russian-controlled territory, such as the transportation hub city of Lyman.
The timing couldn't have been worse. Putin lost Lyman just as he was publicly declaring that the Donetsk region -- in which Lyman sits -- was now annexed by Russia.
At home, Putin is also facing growing criticism from Russians on both the left and the right, who are taking considerable risks given the draconian penalties they can face for speaking out against his "special military operation" in Ukraine.
With even his allies expressing concern, and hundreds of thousands of citizens fleeing partial mobilization, an increasingly isolated Putin has once again taken to making rambling speeches offering his distorted view of history.
(Indeed, his revisionist account defines his rationale for the war in Ukraine, which he asserts has historically always been part of Russia -- even though Ukraine declared its independence from the Soviet Union more than three decades ago.)
But Putin -- a zealous student of Russian history -- is surely aware that defeat in a foreign war has brought down some of his predecessors.
When the Soviets invaded Afghanistan in December 1979, they planned to install a puppet government and get out of the country as soon as it was feasible, as explained in a recent, authoritative book about the Soviet invasion of Afghanistan, "Afghan Crucible" by historian Elisabeth Leake.
Leake writes that the Soviets' "intention was a quick regime change," which was "not meant to be a drawn-out military encounter."
That playbook didn't work for the Soviets in Afghanistan during the 1980s any more than it is working for Putin in Ukraine today.
During the war against the Soviets in Afghanistan, the US was initially reluctant to escalate its support for the Afghan resistance, fearing a wider conflict with the Soviet Union. It took until 1986 for the CIA to arm the Afghans with highly effective anti-aircraft Stinger missiles, which ended the Soviets' total air superiority, eventually forcing them to withdraw from Afghanistan three years later.
In 2022, American weapons are again playing a decisive role in Russian fortunes on the battlefield. At the beginning of the war in Ukraine, the US was also initially leery of deeper involvement, fearing a wider conflict with the Russians.
But the US put those fears to rest relatively quickly, and American-supplied anti-tank Javelin missiles and High Mobility Artillery Rocket Systems (HIMARS), GPS-guided missiles, have helped the Ukrainians to push back against the Russians.
Putin is also surely aware that the collapse of the Soviet Union in 1991 was hastened by the withdrawal of Soviet forces from Afghanistan two years earlier.
Looking further back into the history books, he must also know that the Russian loss in the Russo-Japanese war in 1905 weakened the Romanov monarchy. Czar Nicholas II's feckless leadership during the First World War then precipitated the Russian Revolution in 1917. Subsequently, much of the Romanov family was killed by a Bolshevik firing squad.
Putin, understandably, doesn't want to go the way of either the Soviets or the Romanovs. Which might explain his recent desperate moves: the mobilization of 300,000 additional troops -- a measure that he had long sought to avoid -- and his nuclear weapons saber-rattling.
On February 22 -- just two days before Russia's invasion -- former US President Donald Trump, who has always fawned over Putin, publicly said that the Russian autocrat was "genius" and "savvy" for declaring two regions of eastern Ukraine independent and moving his troops there in a prelude to full-blown invasion.
Putin saw the war in Ukraine as a key to his dream to Make Russia Great Again. Instead, Russia can now no longer pretend to be a great power as it is unable to defeat an enemy on its own borders.
More than seven months into the war, the "genius" myth has unraveled. During the past two weeks, at least 200,000 Russian men have voted with their feet to flee Putin's partial mobilization order. They understand -- despite the Herculean efforts of Putin's propagandists -- that this war is a bloodbath Russia is losing.
Lawrence Freedman, the emeritus professor of war studies at King's College London explains in his just-published book "Command: The Politics of Military Operations from Korea to Ukraine" how Putin plunged his countrymen into the Ukrainian morass.
Freedman writes that Putin is "a tragic example of how the delusions and illusions of one individual can be allowed to shape events without any critical challenge. Autocrats who put their cronies into key positions, control the media to crowd out discordant voices ... are able to command their subordinates to follow the most foolish orders."
Putin's gamble may lead to a third dissolution of the Russian empire, which happened first in 1917 as the First World War wound down, and again in 1991 after the fall of the Soviet Union.
It could unfold once more as Putin's dream of seizing Ukraine seems to be coming to an inglorious end.
Making Russia weak, again.