“JATSZOTER” (playground) proclaims HVG, a magazine, above a graphic of Hungary as a seesaw. Angela Merkel, the German chancellor, is at one end, Vladimir Putin, the Russian president, at the other. It is a fitting image, given that Mr Putin is due in Budapest on February 17th, two weeks after Mrs Merkel. His visit will mostly be about renewing Hungary’s gas contract which expires this year, says Viktor Orban, the prime minister, who wants what he calls a “flexible” arrangement. For his part, Mr Putin wants to show the world that he is not as isolated as some claim.

The Ukraine crisis, and Mr Orban’s links with Russia, have put Hungary in the spotlight. Georgia’s prime minister has just visited; Turkey’s president is expected soon. Western fears of Mr Orban’s autocratic drift have intensified. He caused considerable alarm around the European Union in July 2014 when he declared that Hungary would remain a democracy but become an “illiberal state”, citing the examples of Russia, Turkey and China. Mrs Merkel criticised the term on her visit, but was firmly rebuffed by her host.

On Ukraine, Mr Orban is vacillating between a desire for closer ties with Russia and his obligations as a member of the EU and NATO. Russia is Hungary’s biggest trading partner outside the EU, and supplies most of its gas. Moreover, America’s loss of interest and influence in central Europe points to a greater focus on Germany and Russia, argues Mr Orban.

The cancellation of Russia’s planned South Stream gas pipeline was a blow. Cheap gas is a fundamental pillar of the government’s populist policies, says Peter Kreko of Political Capital, a Budapest think-tank. “The question is what kind of political price President Putin will try and exact. He wants to exert pressure on the EU’s weakest links to break European unity.”

Many in the West think the cosying-up between Mr Orban and Mr Putin has gone too far. Hungary has taken a €10 billion ($11 billion) loan from Russia to upgrade its ageing nuclear power plant. The contract was negotiated in secret and not put out to tender. (Officials cite reasons of national security.) Last year Mr Orban also broke ranks over EU sanctions on Russia, claiming that they did more harm to Europe than to Russia. Hungary has repeatedly called for autonomy for ethnic Hungarians in western Ukraine. Such calls were seen as further weakening the embattled government in Kiev, helping Moscow.

But Mr Orban has since come back into line, supporting Ukraine’s sovereignty and stressing Hungary’s commitment to NATO. He has courted Germany, on whose economy and investment Hungary depends most heavily. European governments understand Hungary’s position on energy, says one Western diplomat, but dissent from the EU’s common position is not an option: “EU member states agree a policy and we all follow it, especially in a high-stakes environment like this one.”

Russia’s relations with Hungary are “isolated from the overall situation in the world,” says Vladimir Sergeyev, Russia’s ambassador to Hungary. Yet this seems implausible. Ukraine, which borders Hungary, casts a long and ever darkening shadow. Doomsday scenarios include the break-up of the country, which could push waves of refugees across the border. Some 200,000 ethnic Hungarians live in western Ukraine, and many could seek sanctuary. Mr Orban may yet have to seesaw back towards the West.