Everyone in Moscow knew that the massive demonstration planned for March 1 was in some way meant to be dangerous.  The mood harked back to the events that caused the 1917 Revolution, or the troubles on the streets that paved the way for Boris Yeltsin to seize power.  The regime had already staged its Anti-Maidan, its own preemptive counterdemonstration where the usual suspects, including Dr. Alexander Zaldostanov’s Night Wolves biker gang, vowed there would be no Color Revolution or other such theatrics in Moscow.

But even so, politicians were tense with expectation.  Perhaps the most active anti-Putin dissident, Alexei Navalny, went out of his way to provoke the police and thus was safely incarcerated for two weeks before the planned demonstration.

And then the unexpected occurred: Boris Nemtsov, one of the few people in Russia who was a Western-style celebrity (famous for being famous), was gunned down in the center of Moscow.  He had gone for a walk across the bridge opposite the Kremlin with a young Ukrainian girlfriend very late at night.  The backdrop was perfect—the floodlit St. Basil’s Cathedral, the Kremlin wall, the river.  The hit was professional—well, almost.

Somehow the assassins had made sure that all the CCTV cameras panning the spot were off.  A street-sweeping machine screened the precise location from view.  Six shots were fired from a Makarov pistol, which was then thrown into the water.

The anti-Putin TV stations immediately went into overdrive, urging people to come out into the streets on March 1 for an anti-Kremlin demonstration.

But then it started to go wrong.  Although the CCTV was off, the state-television station had a hi-res camera fixed on the bridge where Nemtsov was killed.  The street sweeper wasn’t in the way.  The authorities immediately released the footage for broadcast.

As posters and T-shirts immediately appeared with Nemtsov’s face on them, the public mood hardened from suspicion to fear.  Something was wrong.

When Mr. Putin declared that Nemtsov’s assassination was a “provocation,” which in Russian also means a “false-flag” operation, even the most extreme liberal opposition figures agreed with him.

Moscow was in shock.  No one could understand why the charming playboy with a political past had been murdered.  Had it been Alexei Navalny, things would have been different.  But Navalny was safely in jail.  The foreign media leaped to blame the regime for the killing, but the propaganda war in Russia was lost on Day One.

President Putin launched an inquiry by the powerful Investigations Commission, promised Nemtsov’s mother he would find out the truth, then said he would “take personal charge.”  But at that point even stranger things started to happen.  The inquiry popped the rivets in the Kremlin.  The internal-security service (FSB, formerly KGB) began to make progress.

It was the notorious, imprisoned professional hitman Alexei Sherstobitov, interviewed by Gazeta, who guessed the identity of the killers.  It looked, he said, like people “from the North Caucasus.”  They had fired too many times, missed twice; they didn’t kill Nemtsov’s girlfriend, potentially a dangerous witness; they tried to be too clever by using an old Makarov with 20-year-old ammunition.  Yet Sherstobitov was mystified.  “Nemtsov,” he said, “wasn’t a politician.”  It was probably personal.

Navalny appeared equally perplexed.  After the predictable diatribe against Putin, he concluded by saying that it could be people from the Yaroslavl region.

Leaks and announcements came at frightening speed.  Suspects were arrested in the Caucasus.  Ingushetian officials fingered them as people considered close to the leadership of Ramzan Kadyrov, the Putin ultraloyalist who rules Chechnya with a rod of iron.

The FSB announced that it had found the killers.  Their leader was Zaur Dudaev, a senior security chief in Mr. Kadyrov’s republic.  Kadyrov reacted like a rabbit in the headlights, spluttering that Dudaev was a good man, devout, trustworthy.  Matters were clearly very awkward.  The “Sever” battalion, of which Dudaev was supposedly deputy commander, had fought for the rebels in Eastern Ukraine and was supposedly reliable.

Briefly, it looked as if events—or someone in charge of them—had broken the alliance between Moscow and Grozny.  Western propaganda stations began to run stories about how the FSB was jealous of the privileged access given to Chechen security units.

But the awkward moment passed, and the Kremlin recovered.  The president awarded Mr. Kadyrov the Order of Merit, one of the Federation’s highest honors.  The message was patent: We have not lost faith in you.

And the FSB, which had been insisting that the investigation was over, that Dudaev had confessed, that it was all because Nemtsov had supported Charlie Hebdo, suddenly changed its mind.  The investigation would go on; the “customers” who had ordered the assassination would be found.

Two metanarratives were now circulating in Russia.  One was that the United States and her proxies had planned an insurrection in Moscow and hoped to use the Nemtsov murder to rouse public indignation against the regime.  The second was that a fifth column of pro-Western economic and political liberals would mount a coup in the Kremlin.  The idea that Mr. Putin was behind the murder came only from the hard-core opposition, like RAIN-TV.

And it was at this point that Mr. Putin disappeared from public view for almost ten days.

For many months there had been hints that, while Mr. Putin was famous for doing a balancing act between oligarchs, liberals, and nationalists in Moscow, the tightrope was being jerked beneath him.  Not all the siloviki, the officials from the so-called power ministries, were reliable.  Inside the Interior Ministry, which controls the riot police and provides security everywhere except in the Kremlin, there might be enemies.  Even in the Russian military or the FSB, there were false friends.

Junior FSB officials began leaking that they had defied top-level leadership and were insisting on pursuing their investigation of the Nemtsov killing, wherever it went.

There have been major reforms inside Russian security over the last five years.  Older-generation senior officers, who no longer wished to be retired for fear of losing access to lucrative opportunities, had been retained—but their authority had been weakened.  Earlier, as Russia closed her overseas intelligence stations, even those in the “near-abroad,” many officials who had joined the service for its privileges departed.  In the late 1990’s the FSB began to recruit people they called “Young Idealists,” replacing the officers who had left to pursue business opportunities.

By 2015, these officials were in influential positions and felt both excluded and different from their superiors, many of whom had become extremely wealthy.  An attempt to bring Spetsnaz forces under the control of the FSB failed, with the military setting up new elite units controlled by the General Staff.

In Moscow, the rushed attempt to close the investigation failed, and the story changed.  The gunmen under arrest, it seemed, were indeed those responsible.  They withdrew their confessions, but mobile-phone and other intelligence placed them on the bridge at the time and traced them running surveillance on Nemtsov before the shooting.  But their loyalties were not as initially described.  Far from being henchmen of Ramzan Kadyrov—implicating his Chechen regime and, by extension, President Putin—they were denounced as traitors to Kadyrov.

The second version of events claimed that the assassination had been ordered by Chechen rebels fighting for the regime in Kiev and under the instructions of the SBU (Ukrainian intelligence)—itself thoroughly under the influence of the CIA.

The Dzhokhar Dudayev Battalion (DDB) is named after the first president of Chechnya, who was killed in a Russian air strike.  They are fighting in Ukraine in support of Pravy Sektor, the unrepentantly Nazi group from Western Ukraine.  Part of their reason for doing so is to repay various right-wing Ukrainian groups for helping the Chechen rebels—under Saudi direction—in the 1990’s.  The other reason is money.  Professional jihadists have been coming to Ukraine in the last ten years to escape detection, to obtain cheap new identity documents, and to earn cash by protecting illegal businesses such as people-smuggling or amber-digging in Galicia.

The DDB is the largest of several organized jihadist groups (like the Sheikh Mansour Battalion at Mariupol) that operate alongside local private armies.  The size of the private armies is not great.  The DDB may be no more than a few hundred men.  Some of the smaller groups flaunt jihadist insignia and flags, and have connections, according to some reports, to ISIS.

The DDB is led by Adam Osmayev, who was briefly imprisoned in Odessa for a plot to assassinate President Putin in 2012.  Like other prominent Muslim extremists, Osmayev was educated at a British public school and went on to study economics at the University of Buckingham, before returning to Chechnya in 2001.

Mr. Osmayev’s father, Aslanbek, had been purged by Mr. Kadyrov, and his son claims to have been wrongly accused of trying to assassinate the Chechen ruler in 2007.  Mr. Osmayev has also stated that he does not know Zaur Dudayev and despises such rough people.

But things are getting rougher in Eastern Ukraine.  In March two serious attempts were made to assassinate military leaders of the Donetsk People’s Republic.  Commander “Givi” and Alexei Mozgovoi were both lucky to escape with their lives.  In recent weeks, a disturbing number of Ukrainian politicians, veterans of the old regime, have (according to Kiev) all committed suicide.

Whatever the tangled truth of all this, it is clear that the Nemtsov assassination was an attempt—yet again—to embroil the violent affairs of Chechnya with the high politics of the Russian Federation.

Kadyrov is important in Russian politics because his control of the Chechen clans removed the violent wing of what the Russian political class is increasingly calling the fifth column.  Ramzan Kadyrov turned against the Wahhabist jihad in Chechnya after his father’s assassination in 2004 and made his peace with Moscow.  He seized power in Grozny three years later, claiming that his father’s murder had been organized “from outside the country.”

Several attempts by Saudi-sponsored rebel groups inside Chechnya to kill Mr. Kadyrov confirmed Ramzan’s determination to stick with the Kremlin.  Thus, until February 27, Chechen violence no longer threatened Mr. Putin’s regime.

There is now a semi-official narrative, articulated by usually reliable figures with connections to security: The Nemtsov assassination was meant to be the catalyst for a massive demonstration in central Moscow that would end in bloodshed and give President Putin’s enemies the opportunity to oust him.  The plot originated in Ukraine, where jihadist groups were being manipulated by the SBU.  It is possible that opposition politician Alexei Navalny had been the original target of the assassination, but once he was safely incarcerated, the target had to be switched.

If there was such a plot, it has miscarried, thanks to a remarkable political initiative inside the security service in Russia, aimed at clarifying matters that had initially been deliberately muddied.  There is also the unmistakable smell of Western intelligence assets inside the ranks of the siloviki being burned wholesale.

This was a desperate affair, and has come at a very high price—for both sides.  Mr. Putin may still have his Chechen allies, but the balance of the various Kremlin factions, among whom the president has been trying to steer a middle course, has been irretrievably disturbed.

Western demonization of the Russian president has glossed over the truth, which is disappointing to many in Russia, that Mr. Putin is more of a consensus manager than a determined tyrant.  It has been eight years since Mr. Putin declared publicly that Russia was not satisfied with the current strategic situation.  His inability to correct this has only encouraged hawks in both the United States and Poland, the two countries that have driven the crisis in Ukraine.

President Putin’s strategy was to attempt a normalization of Russian domestic politics and an integration of the Russian Federation with the West.  It is true that his optimism on this has faded, though his initial reaction to the assassination was to condemn “this shame” that had returned to the highest level of Russian politics.

For the last six months the two opposing political factions in Moscow—the corporatists, who wish to follow a state-directed route to economic growth, and the liberal integrationists, who want foreign capital to allow existing oligarchs to prosper—have been daring each other to attempt a coup d’état.  Neither has felt strong enough to do so.  Each hoped the other would try—and fail.

Now the siloviki are suddenly better placed than either of the alliances of politicians.  The Russian military have in the last three years seen a major expansion of their budget.  Vast new programs of rearmament are under way, including the modernization of the entire nuclear arsenal.

Russian warships have faced off against NATO in the Eastern Mediterranean, and giant Russian assault ships dock regularly in Syrian ports to replace and repair President Assad’s military equipment.  It is likely that it is not the politicians but the Russian military that is leading policy in Eastern Ukraine.

The most significant change, however, has been in public sympathies and perceptions.  As former U.S. ambassador Michael McFaul acknowledges, the Russian people are now suspicious and unsympathetic to the United States, in particular, and the West, in general.  This translates into sky-high approval ratings for President Putin, whatever reservations Russians have about him.  Ordinary Russians are more concerned now about war and peace, and less concerned about oligarchs and corruption.

But this shift in public opinion is another problem for Mr. Putin.  For the last two years he has been trying not to decide among the powerful groups in Moscow, hoping that he could massage an outcome in which there would be no sore losers and no vengeful winners.  His strategy on Ukraine is logical—no sudden moves, nothing to frighten the neighbors.  But his strategy in Moscow is making less and less sense.

Mr. Putin must know that if he does not move decisively, one of the other groups may well give him a push.