ONLY a day before Kiev exploded, it had seemed that a three-month-long stand-off between protesters and the government of President Viktor Yanukovych was ending. The government had agreed to an amnesty for protesters who, in turn, began to dismantle their barricades and leave the public buildings they had occupied. Mr Yanukovych and the opposition were talking about a coalition government and a return to the 2004 constitution, which limited presidential powers. The world breathed a wary sigh of relief. Yet less than 24 hours later the agreement, and parts of central Kiev, were in flames.

On February 18th riot police stormed Independence Square (Maidan), the scene of a protest camp since December. Officers threw percussion grenades taped up with nails and bolts at protesters, who responded with Molotov cocktails. Live ammunition was used. Plain-clothes thugs, under police protection, rampaged through the centre of Kiev. A trade-union building, which had served as the protesters’ headquarters and had been turned into a makeshift hospital, was in flames. Witnesses said doctors operated on dining tables as riot police threw smoke grenades through the windows. By February 20th dozens of people, including ten policemen, had been killed and hundreds injured.

It is the worst violence Ukraine has known in its 22 years as an independent country, and it is not over. A truce agreed by the government and members of the opposition on February 19th quickly broke down. As more deaths were reported, the defence ministry said it was preparing to use the armed forces. If Ukraine descends into civil war, as many now fear, European security could be tested to the limit. How did this country, which until recently had its sights set on membership of the European Union, turn into a war zone?

From orange to blood-red

Of all the former Soviet republics that won independence in 1991, Ukraine was arguably the most passive. It was also among the richest. Then a country of 52m people (its population has since shrunk to 46m) in an area a little smaller than France, blessed with a good climate, rich land and access to the Black Sea, Ukraine had every reason to prosper. Yet unlike the Baltic states of Estonia, Latvia and Lithuania, it never fought for its sovereignty and did not use its new powers of self-determination to turn itself into a modern state. Instead, Ukraine’s elites understood independence as a right to pillage their country, without having to share the proceeds with anyone.

Compounding the problem is a deeply buried division between the Russian-speaking, industrialised east of the country and Crimea, and the nationalist-minded western Ukraine, once part of Poland and Austria-Hungary until it was annexed by Stalin as part of a non-aggression pact with Nazi Germany in 1939. What held the whole country together was Kiev, recognised by all as the capital.

The seeds of the current crisis were planted by Mr Yanukovych. In 2004 he tried to steal the presidential election, but was defied by mass protests that instead swept his opponents, Viktor Yushchenko and Yulia Tymoshenko, to power. That protest, better known as the orange revolution, ended peacefully when Mr Yanukovych’s predecessor and backer, Leonid Kuchma, refused to use force against protesters, as Mr Yanukovych urged.

Yet such were the failures of Mr Yushchenko and his team that in 2010 the country democratically elected Mr Yanukovych as its president. Tired of Ukraine’s soap-opera politics and the squabbles within its ruling team, the West greeted the arrival of Mr Yanukovych with some relief. It turned a blind eye to his accumulation of ever more political power, interpreting it as a return to order. It was more worried by Mr Yanukovych’s deals with Russia over gas and the Russian Black Sea fleet than it was by the fact that he was replicating the Kremlin’s system of governance, jailing Ms Tymoshenko and steering cash into the hands of his family and close friends. Holding their noses, European Union leaders negotiated with Mr Yanukovych over an association and free-trade agreement that was supposed to move Ukraine closer to Europe. They persuaded themselves that Mr Yanukovych could deliver. Instead, he used the negotiations to extract money and political guarantees from Russia, which in turn seized the chance to tighten its grip over Ukraine, which it was keen to include in a customs union of its own with Belarus and Kazakhstan. After a secret meeting in November with Vladimir Putin, Russia’s president, who promised cheap gas, a $15 billion credit-line and no awkward questions about human rights, Mr Yanukovych ditched the EU deal. When a few hundred people, mainly students, took to the streets to protest against this U-turn, Mr Yanukovych dealt with them as his instinct (and, perhaps, his new Kremlin patrons) advised him: he sent in troops to beat them up. The next day, appalled by such violence, hundreds of thousands of Ukrainians poured out onto the Maidan, scene of the orange revolution. Suddenly it was no longer an issue of a free-trade agreement with the EU or a customs union with Russia. It was about an existential choice between a corrupt and authoritarian post-Soviet system of governance and a European one. This was a more serious threat to the Kremlin than any agreement with the EU. People in a Slavic former Soviet republic were trying to shake off its Soviet legacy, even as Russia itself was tightening the screws. The initial Maidan encampment had the atmosphere of a festival celebrating the birth of the nation. People waved Ukrainian flags and sang the national anthem. Middle-class protesters came to demand an overhaul of the political system, including its compromised opposition. The core of the protesters was made up of people from western Ukraine who refused to recognise Mr Yanukovych’s authority over them. Defended by barricades, the Maidan turned into a free territory inside Kiev. Its discipline gave it a moral superiority over Mr Yanukovych’s government and his Russian backers, who tried to portray the protesters as nationalist radicals. Both Mr Yanukovych and the opposition were taken by surprise. Opposition leaders tried to ride the popularity of the protest, but they were never fully in charge of it.

For Mr Yanukovych to deal with the protesters on his own terms, they first had to be radicalised. This is what has happened over the past three months. The government refused to respond to the protesters’ demands, while pretending to negotiate with opposition leaders, each of whom had his own interests. After two months of camping out in the cold and with no results in sight, the protesters started to get frustrated. To raise the temperature Mr Yanukovych provoked them with draconian laws, apparently copied from Russia’s play-book, which criminalised everybody out demonstrating.

On January 22nd protesters hungry for action and tired of empty talk from both the government and the opposition clashed with the police, lobbing Molotov cocktails. The police shot back. Five people were killed and dozens injured. Some 25 people went missing. The violence stopped as suddenly as it had begun, but the atmosphere had changed. Russian state television portrayed the protesters as Western-sponsored radicals and terrorists.

A period of clashes was followed by calm. Mr Yanukovych cancelled the draconian laws and surrendered his prime minister, Mykola Azarov, who resigned on January 28th. Mr Yanukovych offered the post to Arseny Yatseniuk, leader of Ms Tymoshenko’s party, who turned it down. The quietening of tensions in Ukraine coincided with the grand opening of the Sochi winter Olympics, which was attended by Mr Yanukovych.

The calm did not last. While keeping the opposition distracted with prolonged and fruitless negotiations, Mr Yanukovych, it seems, was marshalling his forces for a crackdown. Worried about contagion spreading from Ukraine to Russia, the Kremlin too was making its own preparations. It steamrollered media outlets that had favourably reported on the protests, and prosecuted its own anti-government protesters. It extended Ukraine’s credit line by another $2 billion as Sergei Glazyev, an adviser to Mr Putin on Ukraine, openly called on Mr Yanukovych to use force against “terrorists” to prevent chaos.

The lull also allowed people on the Maidan to equip themselves with ammunition and protective gear. For more than three weeks the mostly young, male volunteers of the so-called Maidan Self-defence Brigades had been playing soldiers in and around the protest camp, guarding the barricades, decorating their makeshift weapons and armour and talking about the battle to come. The emboldened opposition decided to increase the pressure on Mr Yanukovych. They demanded a constitutional change that would turn Ukraine back into the parliamentary republic it was before Mr Yanukovych took power in 2010. On February 18th, as the barricades came down, opposition leaders called for a “peaceful attack” on the parliament.

The risk that it would not remain peaceful was clear to all. Opposition politicians warned that Mr Yanukovych was seeking an excuse to storm the camp and put an end to the demonstrations. When his faction refused to discuss the constitutional reform in parliament, protests flared. Someone set alight the heavy trucks that had been blocking the roads, and the police, desperate for a fight, charged. The bloodiest day in Ukraine unfolded.

Where east meets west

Mr Putin has never come to terms with Ukraine’s sovereignty, seeing the country as a non-state which ultimately belongs to Russia. He saw the EU’s attempt to sign a deal with Ukraine as little more palatable than NATO’s attempt to draw in Georgia in 2008. That resulted in a five-day war between Russia and Georgia, leaving separatist parts of Georgia occupied by Russian forces and off-limits for NATO. Experiences gathered then may have come in handy in Ukraine. Vladislav Surkov, a Kremlin adviser who is formally in charge of dealing with the Georgian breakaway regions of Abkhazia and South Ossetia, has been handling the Ukraine crisis for Mr Putin, and has been spotted in Kiev and Crimea.

Mr Yanukovych believed that he was trading his refusal to sign an agreement with the EU for Russia’s financial backing. But Mr Putin, who places little trust in Mr Yanukovych, needed firmer guarantees of Ukraine’s dependence on Russia. A civil conflict, blamed on the radicals, not only deters the EU and the West from meddling, but could also give Russia dominance over parts of Ukraine, including Crimea, which it has long coveted.