The greatest challenge to Russian President Vladimir Putin in his more than two decades in power fizzled out after the rebellious mercenary commander who ordered his troops to march on Moscow abruptly reached a deal with the Kremlin to go into exile and sounded the retreat.
The brief revolt, though, exposed vulnerabilities among Russian government forces, with Wagner Group soldiers under the command of Yevgeny Prigozhin able to move unimpeded into the Russian city of Rostov-on-Don and advance hundreds of kilometres toward Moscow.
The Russian military scrambled to defend Russia's capital.
Under the deal announced Saturday by Kremlin spokesman Dmitry Peskov, Prigozhin will go to neighbouring Belarus, which has supported Russia's invasion of Ukraine. Charges against him of mounting an armed rebellion will be dropped.
The government also said it would not prosecute Wagner fighters who took part, while those who did not join in were to be offered contracts by the Defence Ministry. Prigozhin ordered his troops back to their field camps in Ukraine, where they have been fighting alongside Russian regular soldiers.
Putin had vowed earlier to punish those behind the armed uprising led by his onetime protege. In a televised speech to the nation, he called the rebellion a betrayal and treason.
In allowing Prigozhin and his forces to go free, Peskov said, Putin's highest goal was to avoid bloodshed and internal confrontation with unpredictable results.
Some observers said Putin's strongman image has taken a hit.
Putin has been diminished for all time by this affair, former US Ambassador to Ukraine John Herbst said on CNN.
Moscow had braced for the arrival of the Wagner forces by erecting checkpoints with armoured vehicles and troops on the city's southern edge.
About 3,000 Chechen soldiers were pulled from fighting in Ukraine and rushed there early Saturday, state television in Chechnya reported. Russian troops armed with machine guns put up checkpoints on Moscow's southern outskirts. Crews dug up sections of highways to slow the march.
Wagner troops advanced to just 200 kilometres from Moscow, according to Prigozhin. But after the deal was struck, Prigozhin announced that he had decided to retreat to avoid shedding Russian blood.
Prigozhin had demanded the ouster of Defence Minister Sergei Shoigu, whom Prigohzhin has long criticised in withering terms for his conduct of the 16-month-long war in Ukraine.
On Friday, he accused forces under Shoigu's command of attacking Wagner camps and killing a huge number of our comrades.
If Putin were to agree to Shoigu's ouster, it could be politically damaging for the president after he branded Prigozhin a backstabbing traitor.
The US had intelligence that Prigozhin had been building up his forces near the border with Russia for some time. That conflicts with Prigozhin's claim that his rebellion was a response to an attack on his camps in Ukraine on Friday by the Russian military.
In announcing the rebellion, Prigozhin accused Russian forces of attacking the Wagner camps in Ukraine with rockets, helicopter gunships and artillery.
He alleged that Gen. Valery Gerasimov, chief of the General Staff, ordered the attacks following a meeting with Shoigu in which they decided to destroy the military contractor.
The Defence Ministry denied attacking the camps.
Congressional leaders were briefed on the Wagner buildup earlier last week, a person familiar with the matter said. The person was not authorised to speak publicly and spoke to The Associated Press on the condition of anonymity. The US intelligence briefing was first reported by CNN.
Early Saturday, Prigozhin's private army appeared to control the military headquarters in Rostov-on-Don, a city 660 miles (over 1,000 kilometres) south of Moscow, which runs Russian operations in Ukraine, Britain's Ministry of Defence said.
Russian media reported that several helicopters and a military communications plane were downed by Wagner troops. Russia's Defence Ministry has not commented.
After the agreement de-escalated tensions, video from Rostov-on-Don posted on Russian messaging app channels showed people cheering Wagner troops as they departed.
Prigozhin was riding in an SUV followed by a large truck, and people greeted him and some ran to shake his hand. The regional governor later said that all of the troops had left the city.
Wagner troops and equipment also were in Lipetsk province, about 360 kilometres south of Moscow.
Moscow Mayor Sergei Sobyanin declared Monday a non-working day for most residents as part of the heightened security, a measure that remained in effect even after the retreat.
Ukrainians hoped the Russian infighting would create opportunities for their army to take back territory seized by Russian forces.
These events will have been of great comfort to the Ukrainian government and the military, said Ben Barry, senior fellow for land warfare at the International Institute for Strategic Studies. He said that even with a deal, Putin's position has probably been weakened.
Ukrainian President Volodymyr Zelenskyy said late Saturday, shortly before Prigozhin announced his retreat, that the march exposed weakness in the Kremlin and showed all Russian bandits, mercenaries, oligarchs that it is easy to capture Russian cities and, probably, arsenals.
Wagner troops have played a crucial role in the Ukraine war, capturing the eastern city of Bakhmut, an area where the bloodiest and longest battles have taken place. But Prigozhin has increasingly criticised the military brass, accusing it of incompetence and of starving his troops of munitions.
The 62-year-old Prigozhin, a former convict, has longstanding ties to Putin and won lucrative Kremlin catering contracts that earned him the nickname Putin's chef.
He and a dozen other Russian nationals were charged in the United States with operating a covert social media campaign aimed at fomenting discord ahead of Donald Trump's 2016 presidential election victory. Wagner has sent military contractors to Libya, Syria, several African countries and eventually Ukraine.