TIME was when cash-strapped Latin American governments would turn to the IMF for the bitter medicine of its bail-outs. No longer. Over the past dozen years the supercycle of rising commodity prices has swelled the region’s coffers, while even the most fiscally incontinent autocrat has been able to count on the Chinese chequebook.

Now the bonanza is over. Commodity prices are back to their trough of the great recession of 2008. And the bank manager in Beijing is learning to say no. With queues outside sparsely stocked supermarkets in Caracas and investors fearing a default on his country’s foreign debt, Venezuela’s president, Nicolás Maduro, flew to China this month to beg for emergency cash. All he got was an apparent repackaging of an existing $20 billion in credits for long-term investments.

Mr Maduro’s trip coincided with a meeting of Latin American foreign ministers in Beijing on January 8th and 9th. President Xi Jinping, who has visited Latin America in each of the past two years, told his guests that by 2019 he wants to see a doubling of China’s trade with the region (it rose from $10 billion in 2000 to $257 billion in 2013), and a similar rise in investment. Ecuador’s Rafael Correa, another visitor, is a more prudent petrocrat, having responded to the fall in oil prices with a budget cut. He came away with fresh loans totalling $7.5 billion.

But China has now made it clear that it is not prepared to be an unconditional lender of last resort to deadbeats, even if they claim political affinity, as Mr Maduro does. According to Margaret Myers, a China specialist at the Inter-American Dialogue, a think-tank in Washington, Chinese officials have begun to keep a close eye on how Venezuela spends their loans. Worries about default are surfacing in Chinese publications, she says.

The maturing of China’s relations with Latin America coincides with other geopolitical shifts in the region. Venezuela’s aspiration to create an anti-American alliance has foundered with its economy. Plunging oil revenues cast doubt over subsidies to 17 Caribbean and Central American countries that assured it a solid voting block in international organisations. Brazil’s claim to regional leadership is also in abeyance. Dilma Rousseff began her second term on January 1st with a weak mandate, facing a fiscal squeeze and a disabling corruption scandal at Petrobras, the state oil company.

Barack Obama, though mainly for domestic reasons, is doing much to assuage Latin American grievances against the United States. His decision, announced last month, to normalise relations with Cuba and to loosen the embargo against the communist island was widely applauded. So was his earlier immigration reform by executive action. Mr Obama has downplayed the “war” on drugs (which some Latin Americans complained was a war against them). Further evidence of his administration’s new appetite for taking the initiative in the region is a Caribbean “energy summit”, to take place in Washington on January 26th. It is aimed at deploying multilateral loans, technical help and private investment as an alternative to Venezuelan subsidy. The administration is also mobilising aid for Central American countries facing drug violence.

So will the United States start to recover the ground it has lost in the region? One test will come at the Summit of the Americas in Panama in April, the first such gathering that Cuba’s Raúl Castro will attend. Mr Obama wants the summit to discuss democracy and human rights. Latin America is now prepared to have that discussion, says Andrés Rozental of the Mexican Council on Foreign Affairs, a think-tank. “It may not be the most public part of what happens in Panama, but it will be part of it,” he says.

Both Chinese and American officials deny that they are competing for influence in Latin America. But that is what it looks like. To left-of-centre governments, China’s offer of loans, investment (especially in infrastructure), scholarships and non-interference in politics remains attractive. Against that, the United States offers an appeal to shared values and access to what is still the world’s biggest market and its best source of technology.

These do not have to be mutually exclusive. And in both cases, there are frictions. China sucks up Latin America’s commodities and undercuts its manufacturers. A Chinese investor is building an environmentally damaging canal on neocolonial terms in Nicaragua. Some of Mr Obama’s initiatives are hostage to the Republican-controlled Congress. But after a decade in which China seemed to carry all before it in Latin America, at least the United States has now started to compete in this new Gran Juego.