LESS than a decade ago little doubt hung over where the newly independent states of Central Asia had to pump their huge supplies of oil and gas: Russia, their former imperial overlord, dominated their energy infrastructure and markets. Yet today, when a new field comes on stream, the pipelines head east, to China. As if to underline the point, this week China’s president, Xi Jinping, swept through Central Asia, gobbling up energy deals and promising billions in investment. His tour left no doubts as to the region’s new economic superpower.

In Turkmenistan, already China’s largest foreign supplier of natural gas, Mr Xi inaugurated production at the world’s second-biggest gasfield, Galkynysh. It will help triple Chinese imports from the country. In Kazakhstan $30 billion of announced deals included a stake in Kashagan, the world’s largest oil discovery in recent decades. In Uzbekistan Mr Xi and his host, President Islam Karimov, unveiled $15 billion in oil, gas and uranium deals, though details in this opaque country were few.

China is the biggest trading partner of four of the region’s five countries (the exception being Uzbekistan). During Mr Xi’s trip, Chinese state media reported that trade volumes with Central Asia topped $46 billion last year, up 100-fold since the countries’ independence from the Soviet Union two decades ago. Though neither side puts it like this, China’s growing presence clearly comes at Russia’s expense. Russia still controls the majority of Central Asia’s energy exports, but its relative economic clout in the region is slipping—other than as a destination for millions of migrant labourers. For years Russia has treated the region as its exclusive province, insisting on buying oil and gas at below-market rates through Soviet-era pipelines, while re-exporting it at a markup. The practice helped drive Kazakhstan and Turkmenistan, both with huge energy reserves, into China’s arms.

Yet Russia and China have much riding on their bilateral relationship. The government in Moscow is eager to benefit from its eastern neighbour’s economic might, while in Beijing policymakers view Russia as a critical ally on the world stage. (Knowing the premium China places on protocol, it was no accident that Mr Xi’s very first official visit as president was to Moscow; and that he went to St Petersburg for the G20 summit in the middle of his Central Asian tour.) All this suggests the two giants will aim to co-operate as much as compete, at least for the moment. As for Central Asians, says Vasily Kashin, a Moscow-based China expert, Russia has accepted that “they will try to get the best deals out of this rivalry.”

When it comes to security issues in Central Asia, in public China still defers to Russia. Both look warily on as NATO withdraws from Afghanistan. China’s chief concern is the threat posed by Uighur separatists and their sympathisers in Central Asia. And so, in security matters too, China’s influence is growing. As The Economist went to press, Mr Xi was expected in Bishkek, capital of Kyrgyzstan, to attend the annual summit of the Shanghai Co-operation Organisation, a block which China was instrumental in founding. A chief aim is to counter the “three evil forces” of terrorism, extremism and separatism.

Arguably, Chinese investment in Central Asia promotes that goal, by improving living standards and thus stability in a region that shares a 2,800km (1,750-mile) border with Xinjiang, China’s westernmost province and Uighur homeland. Yet China’s soft power is undermined by a beast it is not good at fighting: resentment. Chinese contractors are flooding into Central Asia, building roads and pipelines and even, in Tajikistan’s capital, Dushanbe, the government buildings. The cruel irony is not lost on the millions of unemployed men leaving for Russia to look for jobs. But it is lost, says Deirdre Tynan of the International Crisis Group, a think-tank, on policymakers. “Central Asia’s governments see China as a wealthy and willing partner, but on the ground little is being done to ease tensions between Chinese workers and their host communities,” she warns.

A few years ago a Kazakh activist, protesting against his government’s plans to lease land to China, publicly decapitated a toy panda. But local Sinophobia does not stop at silly gestures. When Kyrgyzstan ceded disputed territory to China a decade ago, the protests which that set off eventually brought down the president. More recently Chinese workers in Kyrgyzstan have been getting badly beaten up. Central Asia is not yet happily in the Chinese fold.