A RELATIVE hiatus in the fighting in eastern Ukraine (at least until this week) and a relative stabilisation in the Russian economy are prompting two questions. Is the worst of the war over and might better economic news calm the Kremlin—or is this a lull before a new storm?

The economic situation is not as bad as many predicted four months ago. Having lost half its value, the rouble has stabilised and even started to strengthen, thanks in part to a recent rise in oil prices. Inflation is running at 17% but is rising more slowly than many feared. Instead of a 5% contraction, the economy may shrink by only 3% this year. “The situation is not as catastrophic as many people thought,” is how a senior Russia banker sums up the mood.

Yet the fragile economic balance is not being used by Vladimir Putin as an argument for returning to peace and prosperity, but rather as evidence that he is standing strong against Russia’s adversaries. The state media have trumpeted the strengthening of the rouble against the dollar and the euro as a victory in the face of American and European enemies determined to ruin Russia.

The Kremlin’s narrative of war has long moved beyond Ukraine to the West in general. The claim that their country is at war may be news to Americans, but it has been drilled into the minds of many ordinary Russians. The prospect of a war with the West is now a big concern for public opinion. Some 81% of the population sees America as a threat, the highest proportion since the Soviet Union fell apart.

According to this narrative, Russia is under attack on all fronts—economic, ideological, Middle Eastern, European—and must respond accordingly. This week’s decision to sell the S-300 missile system to Iran is part of this response (see article). As for the supposed threat from the European Union, Channel One news recently instructed its viewers: “Put crudely, the EU started and flourished as a mechanism for redistributing the gains from the collapse of the USSR and former communist bloc. At some stage, however, the flow of resources from conquered markets started to run out and expansion to the east was the only option.” This expansion, it adds, has now been stopped by Russia; so the EU, deprived of new sources of prosperity, may soon crumble.

In this world of mirror images, America serves as Russia’s reflection and alter ego. It ascribes to America its own actions: incitement of violence in Kiev, support of extreme nationalists in eastern Ukraine, military involvement in the conflict. In a recent article, Sergei Naryshkin, Speaker of the Russian parliament, blamed America for “unleashing a military-political adventure” in Ukraine and stalling its peaceful resolution. “America needs the continuing bloodshed in the Donbas as a means of achieving something important for itself,” he wrote. The sanctions against Russia and the information hysteria in the Western media are a cover for America’s economic “gangsterism”, he added.

What are Russia’s motives and goals in this confrontation, and is it now trapped in a spiral of aggression? Russian officials talk obsessively of geopolitics, but the answers depend not on what the West does but on how the Kremlin calculates its risks at home, since staying in power is its main goal. A study commissioned by Alexei Kudrin, a former finance minister, and conducted by a group of Russian sociologists led by Mikhail Dmitriev of the New Economic Growth, a think-tank, suggests that the roots of Mr Putin’s actions in Ukraine lie in the Kremlin’s need to solidify its legitimacy after the growing discontent that erupted into street protests during the winter of 2011-12.

Those protests were driven mainly by Russia’s middle class, frustrated by its lack of prospects. After a decade of rapid income growth that boosted living standards, priorities shifted to such aspirations as better justice, education and health care that Mr Putin’s regime of crony state capitalism could not provide. In the eyes of the middle class, Mr Putin was becoming a symbol of stagnation rather than stability—so his ratings began to fall. Trust in the state media also wobbled. Observers started to compare the situation to the mid-1980s, when a frustrated intelligentsia became a driving force behind Mikhail Gorbachev’s perestroika. The protests in Russia’s larger cities started to resonate with economic and social discontent in poorer provinces, and risked erupting into an open social conflict.

Russia’s annexation of Crimea arrested this trend. Alexei Navalny, a leader of the protests of 2011-12 who memorably named Mr Putin’s United Russia a party of crooks and thieves, says that the president has hijacked the political agenda by substituting imperial nationalism for building a modern state. The annexation of Crimea won over provincial Russia and legitimised his rule even in the eyes of many who had protested against him two years earlier. As Mr Dmitriev sees it, unmet hopes of personal fulfilment were assuaged by symbolic victories for the state.

The war in eastern Ukraine and the economic crisis have turned the euphoria associated with Crimea into a paranoid and defensive patriotism aimed against the West, pushing Mr Putin’s approval ratings up to nearly 90%. The Kremlin can ill afford a real military clash with the West, but it will claim any signs of Western weakness as victories. To demonstrate its strength, it is brandishing its nuclear arms and flexing its muscles all around NATO’s borders. Dmitri Trenin of the Carnegie Moscow Centre, a think-tank, says Mr Putin wants his nuclear threats taken seriously, and adds that the risk of nuclear war is greater than at any time since the 1962 Cuban missile crisis. But the immediate goal of such intimidation is to persuade the West to drop sanctions, which would be presented at home as a huge victory.

Against this background a resolution of the Ukrainian crisis and de-escalation of tensions with the West would push the focus back onto economic and social problems, lowering Mr Putin’s ratings, just as happened after Russia’s war in Georgia in 2008. A continuation of the war in Ukraine and the stand-off with the West will keep his ratings up for longer. But while this may benefit Mr Putin, it risks leaving Russia isolated and economically stagnant.

Russia’s budget cuts are a good guide to Mr Putin’s priorities. The upkeep of the Kremlin and spending on the army and security services take 40% of the entire budget. But spending on health care and infrastructure has been reduced twice as much as spending on defence. Among other winners in the budget are the state media which spew out hatred and aggression.

The object of this aggression can vary: two years ago it was migrants and corrupt officials. Now it is the West, “national traitors” and a “fifth column” that included Boris Nemtsov, a liberal politician assassinated in Moscow in February. In this way the Kremlin’s aggression has become a narcotic that may lead to an overdose, causing it to lose control. Indeed, the mood could one day switch from an external enemy back to Mr Putin himself, not least because the image of America constructed by the Kremlin’s propaganda bears such a close resemblance to the reality of Russia.