Putin was expecting an easy victory in Ukraine.

Over and over again, demoralized and ill-equipped Russian soldiers have raped, tortured, and looted their way through Ukrainian towns before fleeing in disgrace.

Just weeks after Putin declared at a triumphant rally on Red Square that the city was "Russian forever," Russian forces withdrew from Kherson.

Putin's rule seems to be secure for now. Failure at the front can lead to a loss of authority at home, sometimes with deadly consequences.

Tsar Nicholas II

Tsar Nicholas II
Nicholas II after his abdication in March 1917.
Library of Congress, Prints & Photographs Division

The fate of Nicholas II is one of the most extreme scenarios.

Russia had the largest army in Europe. In 1914, over 5 million men were called up.

The war effort was hampered by the autocracy's weak infrastructure and transportation links. The Germans took huge swathes of Russian-controlled territory and a million Russians died.

The Romanov dynasty's out of touch scion tried to improve the situation by taking command of the armed forces himself.

World War II Russian soldiers Tannenberg
Captured Russian soldiers after the defeat at Tannenberg, in present-day Poland, on August 30, 1914.
Hulton Archive/Getty Images

Riots broke out in Petrograd in February 1917 when strikes and street protests began.

The tsar was put under house arrest with his family a few weeks after he abdicated on the railroad siding.

The armistice was signed after the Bolsheviks took over.

The Romanovs' 300-year reign was brought to an ignominious end in July 1918 when the tsar and his family were shot and stabbed by the Bolsheviks.

Nikita Khrushchev

Nikita Khrushchev
Soviet Premier Nikita Khrushchev.
Getty Images

Nikita Khrushchev was felled by a foreign-policy blunder that resulted in no deaths.

The U-2 spy plane took pictures of the Soviet nuclear missile sites in Cuba. The world was on the verge of destruction as a result of the US and Soviet Union's confrontation.

Secretary of State Dean Rusk said, "We have been eyeball to eyeball, and someone just blinked." Khrushchev said that the missiles would be removed.

John Kennedy Nikita Khrushchev
Khrushchev with President John F. Kennedy in Vienna.
Evelyn Lincoln/Reuters

Khrushchev's position in the leadership was weakened.

He could have stepped down with dignity after his 70th birthday in April 1964, but instead he was forced into retirement by a group of rivals who supported the KGB.

Khrushchev's removal was possible because he wanted to reject Stalin's rule. The peaceful overthrow of Khrushchev was seen as a sign of his success.

He spent the last years of his life writing his memoirs.

Mikhail Gorbachev

Mikhail Gorbachev
Mikhail Gorbachev in Moscow in March 1989.
VITALY ARMAND/AFP via Getty Images

Gorbachev presided over a military failure that undermined his authority and brought the Soviet Union down.

Gorbachev took over the war in Afghanistan when he came into office in 1985. The last soviet troops left Afghanistan in February 1989 after Gorbachev gave up on trying to improve the situation.

Gorbachev was not willing to use force to preserve the Soviet empire. The fall of the Berlin Wall, Poland's free elections, and the emergence of sovereignty movements within the Soviet republics all took place in 1989.

In August 1991, senior military officers attempted to overthrow Gorbachev. The country fell apart after the hardliners failed to take control.

The dissolution of the Soviet Union was presided over by Yeltsin. Yeltsin started a fight against Russia's independence that almost ended him.

Boris Yeltsin

boris yeltsin
Russian President Boris Yeltsin waves to demonstrators protesting an attempted coup against Gorbachev in August 1991.
EUTERS/Michael Samojeden

Chechnya, a small Muslim republic in the north Caucasus, refused to sign a union treaty with the Russian Federation.

A small victorious war would boost Yeltsin's approval ratings, according to one of his advisors. He decided to go in.

Yeltsin was confident that Chechnya would fall. They were in a war against a group of people who wanted to overthrow their oppressor. Russian forces retaliated against civilians after they were defeated.

Yeltsin's popularity plummeted even further as the destruction in Chechnya was broadcasted. He was reelected in 1996 despite the fact that he had been re-elected with the help of fraud.

Vladimir Putin Gudermes Chechnya
Putin, then Russia's acting president, signs autographs for soldiers in Chechnya on January 1, 2000.
AFP/AFP via Getty Images

Yeltsin signed a peace treaty in 1997 after the First Chechen War claimed 80,000 lives.

Putin took up the cause of avenging Russia's humiliation when Yeltsin appointed him as prime minister.

Putin said his goal was to "bang the hell out of those bandits". He renewed bombing in Chechnya by the end of his first month.

Russia's assault was more popular and effective than in the past. Putin wore a flight suit to celebrate Russia's victory in Grozny in 2000.

Putin's fate

Vladimir Putin grave gravestone in Ukraine
A mock grave for Russian President Vladimir Putin near Zaporizhzhya in Ukraine on May 9.
Rick Mave/SOPA Images/LightRocket via Getty Images

Putin expected to repeat his success in the Second Chechen War in order to regain control over Ukraine. Yeltsin encountered a population united against an threat.

Putin's position is relatively stable compared to previous leaders. The United Russia party has engaged in massive electoral fraud.

More people have been swept up by the recent partial Mobilization of several hundred thousand men than during the peak of the war in Afghanistan, but still less than during World War I.

Hundreds of thousands of Russians have fled abroad to escape the draft, but there have been isolated incidents of violence at training camps. The law that made desertion and refusing military service a crime has helped ensure compliance.

putin internet research agency
Prigozhin, left, and Putin at a factory owned by Prigozhin outside St. Petersburg in September 2010.
Alexei Druzhinin/AP

Kremlin spin doctors say that NATO is to blame for the Ukrainian crisis. Most Russians who oppose the war either keep quiet or emigrate because they face up to 15 years in jail for defaming the Russian armed forces.

Russia has not experienced the economic turmoil of World War I despite the continued impact of Western sanctions.

hawks like Yevgeny Prigozhin who do not target him personally have criticized the war's failures. The mix of forces on the ground allows Putin to keep his distance from the losses.

It is possible that disgruntled generals could overthrow Putin. Russia's prior experience shows that a military takeover would be unlikely.

putin military training
Putin meets troops at a training center outside the town of Ryazan on October 20.
Mikhail Klimentyev/Sputnik/AFP via Getty Images

In the event of a palace coup, Putin wouldn't leave willingly, putting anyone who was involved at great risk. Putin's hold on power is not assured. The situation in Russia could get out of hand if more soldiers die.

The downfall of Nicholas II shows how difficult it can be. The last tsar of Russia was worshiped as an autocrat. He lost the support of most of the population and his closest allies after the war.

Widespread corruption, stagnant wages, and a low standard of living are just some of the problems that have been revealed by the invasion of Ukraine.

Russia's system is authoritarian but brittle. If Putin's war fails, who will be left to defend him?

Joy Neumeyer is a historian.