The first Chechen war between 1994 and 1996 led to a humiliating defeat for the Russian army and then-Pres. Boris Yeltsin. Many soldiers — underpaid and badly treated by their superiors — saw the restive mountain republic as not worth dying for.

The Russian experience in Afghanistan was still fresh. But military leaders forgot or deliberately ignored the war’s counter-insurgency lessons.

Chechens who fought against the Russian army were sometimes former Soviet soldiers, including Dzhokhar Dudayev — the young republic’s first post-Soviet leader.

Others were police officers and civilians with no prior combat training. They carried small arms, light weapons and had few heavy artillery. They had no air force.

Despite the lack of equipment, the old soldiers and cops were ready to fight for an independent Chechnya. This combination of experience and high morale was more than the Russian conscripts could handle.

Systemic corruption also weakened the Russian military. It was an enemy just as dangerous as the Chechen guerrillas.

Galeotti describes how the intersection of corruption, opportunism and Chechen patriotism led to a Russian defeat. But this is secondary to his book’s main concern — which is an analysis of intra-Chechen ideological and political struggles during and between the wars.

That struggle, Galeotti explains, was not without precedent. Even during the 19th century wars of independence — which the Chechens lost — brothers from a single family often fought on opposite sides.

This infighting resurfaced with a vengeance after Chechnya won its independence. Factions fought each other for control of the state, which went a long way toward destroying Chechen military discipline, and later contributed to the country’s military defeat.

Islamism swept through the region — and the dream of a greater “Caucasian Emirate” took hold of some groups. But the Islamists’ overreached by launching a failed invasion of Dagestan, which helped provoke domestic support in Russia for a new war.

Both sides resorted to brutality, torture and arbitrary executions. Chechen terrorists targeted civilians in Russia, and Russian Pres. Vladimir Putin extended a hand to pliable Chechen leaders.

“On the one hand,” Galeotti notes, the Russians “were ruthless in their control of the Chechen population, but on the other, they eagerly recruited Chechens, including rebel defectors, to a range of security units.”

The Kremlin’s focus on enlisting collaborators proved decisive, and defections from the Chechen side rose exponentially. Two clans that had fought the Russians in 1994 — the Yamadayevs and Kadyrovs — struck a bargain with Moscow in 1999.

Russian troops overran Grozny. After 2000, the war evolved into an insurgency.

The Kadyrov patriarch, Akhmad, died during an explosion at a Victory Day parade in 2004. His son, Ramzan Kadyrov, concluded the grand bargain with Moscow, and his family is still in charge of the region to this day.

But the intra-Chechen struggle continued, even as the second Chechen war wound down and Russian troops withdrew. Assassins linked to Kadyrov have killed the three leading members of the Yamadayev clan after it dared to maintain its independent power base following the war.

Forced disappearances, murders and other human rights violations persist throughout the country. On Dec. 4, a battle between police and an insurgent cell broke out in Grozny — demonstrating that the conflict is far from settled.