Trading political freedoms for security and economic growth - that's the gist of the social contract which Russians struck with Vladimir Putin at the end of the tumultuous 1990s. But coupled with economic woes, the latest terror attack in St Petersburg raises doubts about his ability to keep his promise.



Fair or not - most Russians consider the decade that preceded Putin's rise to power as the darkest period in their lives. This was the time when the country was struck by the triple calamity of extreme poverty, rampant crime and military conflict in the North Caucasus. At the end of the decade, the latter spilled out of the region into large urban centres, with the insurgents resorting to terror attacks.

'Russia's number one terrorist'

That tactic was pioneered by Shamil Basayev, a Chechen militant who shot to fame in November 1991, when he hijacked a Russian passenger plane with 178 people on board. He surrendered to the Turkish authorities after freeing the hostages and was miraculously allowed to return to Chechnya. Next year, he displayed immense cruelty fighting in Georgia on the side of pro-Russian Abkhazian separatists, who were closely coordinated by elements in the Russian military.



Despite that short-lived collaboration, he gained the title of Russia's number one terrorist in 1995, when he captured around 1,600 hostages in a hospital in the town of Budyonnovsk, forcing the Russian government to start talks with the Chechen leadership and eventually strike a peace agreement that ended the first Chechen war. In 1996, a bomb went off for the first time in the Moscow metro, killing four.



In the 1990s, the margin between terror attacks and traditional guerrilla operations was blurred. Targets tended to be found inside the North Caucasus region and to a varying extent related to the Russian military. The death toll was relatively low and hostages were mostly taken for ransom.

OPINION: Trump - Putin's best frenemy

But during the interim between two Chechen wars, Basayev and the radical wing of Chechen liberation movement underwent an ideological transformation influenced by militants from the Middle East who became later known as al-Qaeda. Basayev abandoned the Chechnya independence cause in favour of creating an Islamic state in the whole of North Caucasus. The radicals also started squeezing out more traditional nationalists, with Basayev appointed the commander of Chechen armed forces.



That also transformed the conflict, which saw a radical escalation in 1999 that happened to coincide with the transition of power in Moscow. On March 19 that year, a powerful bomb went off at a busy market in Vladikavkaz, killing 52. A week later, the ailing president Boris Yeltsin appointed the young chief of the Federal Security Service, Vladimir Putin, the head of the Security Council, a body that coordinated Russian military efforts in the North Caucasus.



On August 7, Chechen forces invaded the neighbouring Dagestan with the aim of creating a pan-Caucasian caliphate, a goal publicly declared by Basayev. Two days later, Yeltsin elevated Putin to the post of prime minister and proclaimed him successor to the presidential post.



Just three weeks later, the outgoing and incoming Russian leaders faced an unprecedented disaster when devastating terror attacks hit Moscow and two other cities. This time, the terrorists targeted typical high-rise apartment blocs, in which the vast majority of Russians reside, killing nearly 300 civilians. The message was clear - no one in Russia is safe.

Power transfer

Those attacks had a dramatic psychological effect on Russians and on Putin himself, playing a crucial role in turning the man, who was then seen as a random and rather hapless figure, into what he is now. The result was a massive consolidation of once divided society around the unlikely leader.

Putin chose not to enter talks with Basayev, in the manner of his predecessors. Instead, after rooting out the militants in Dagestan, he ordered Russian troops to march on Chechnya. As the Russian army besieged the Chechen capital, Grozny, on New Year's Eve, Yeltsin announced that he was stepping down and leaving Putin in charge. The new Russian leader chose to spend his first new year in office celebrating with soldiers on the front line.



The renewed conflict proceeded with numerous atrocities committed by both sides, often by former rebels co-opted by the Kremlin and used to conducting mopping-up and punitive operations. In response, the rebels took the insane brutality of terror attacks one level up, by seizing hundreds of hostages in Dubrovka theatre in Moscow in 2002 and in Beslan school in 2004. Both attacks ended in bloodbaths, often blamed on unprofessionalism of Russian security forces. But Putin masterfully used these tragedies in order to marginalise the opposition and concentrate power in his own hands, with a majority of Russians supporting both trends.



But despite numerous setbacks Putin was gradually taking the upper hand. Basayev was killed by a rocket attack in 2006. Yet, even as insurgency in Chechnya was largely quelled, the rebels managed to detonate bombs at two stations of the Moscow metro in 2010 and at Domodedovo international airport in 2011, killing dozens.



But the wave of terror eventually waned, while the economy and personal incomes were rising at high pace. Putin could have gone into history as Russia's most successful leader in two centuries, but he chose to stay in power and preside over an economic recession that was caused by an oil price slump in 2014 and the country's international isolation over its intervention in Ukraine.



The last thing he needed in those circumstances was another terror attack in a large urban centre. But it happened in his native city, and on the day of his visit. There is hardly a way for him now to pull the old trick of consolidating in the face of perceived adversity - the way he did in 1999 or when he seized Crimea from Ukraine in 2014. The best he can do is to mitigate the negative PR impact and pray there are no new calamities in store.

Leonid Ragozin is a freelance journalist based in Moscow.

The views expressed in this article are the authors' own and do not necessarily reflect Al Jazeera's editorial policy.