WHAT has happened to the “harmonious world” that China's president, Hu Jintao, once championed? Where is the charm offensive that was meant to underpin it? Recent revelations about its military programmes are the latest Chinese moves to have unsettled the world. Strip the charm from Chinese diplomacy and only the offensive is left. Sino-American relations are at their lowest ebb since a Chinese fighter collided with an American EP-3 spyplane a decade ago.

In the past few weeks China has made a splash with progress on an anti-ship missile and a stealth fighter jet. Every country has legitimate interests and the right to spend money defending them, especially a growing power like China. But even if their purpose is defensive, such weapons will inevitably alarm America and China's neighbours. In the harmonious world China says it seeks, assertiveness needs to be matched with reassurance and explanation. Yet China undermined the confidence-building visit this week to Beijing of Robert Gates, America's defence secretary (see picture), when it staged a test flight of the new jet (see article). It was an unfortunate curtain-raiser for the visit of China's president, Hu Jintao, to Washington on January 18th.

Sino-American relations have been deteriorating for a year. On his first visit to China in 2009 President Barack Obama was treated with disdain, and the Chinese government reacted with fury when he sanctioned arms sales to Taiwan that were neither a surprise nor game-changing and saw the Dalai Lama—also routine for American presidents. China broke off military-to-military contacts and officials suddenly stopped returning American diplomats' calls.

Tensions have also been growing with neighbours that China was once careful to cultivate. China has more forcefully asserted sovereignty over great swathes of the South China Sea. It overreacted after a Chinese trawler rammed a Japanese coastguard vessel in contested waters controlled by Japan. It got into a spat with India over visas for Kashmiri residents. And it failed to condemn the North Korean sinking of a South Korean corvette and the shelling of a South Korean island. Even Africa, once extremely friendly to China, is having doubts. Anger in Zambia is growing over Chinese managers who shot at mine workers.

Whereas a single incident sparked the spyplane crisis, today's tensions are the culmination of lots of different things. China's new raw-knuckle diplomacy is partly the consequence of a rowdy debate raging inside China about how the country should exercise its new-found power. The liberal, internationalist wing of the establishment, always small, has been drowned out by a nativist movement, fanned by the internet, which mistrusts an American-led international order. Western hawks conclude that China has broken with the pragmatic engagement it has followed for three decades. Its tough new line, they say, warrants an equally tough response.

Don't underestimate America

China's recent behaviour is in part the product of a miscalculation, dating from the global financial crisis. Many Chinese believe that America's power has gone into an inexorable decline. Chinese leaders' preoccupation with sweeping changes to the Communist Party hierarchy in 2012 may be helping to reinforce this belief. At a time of domestic uncertainty, running down the foreign opposition is popular.

America is certainly losing clout in relative terms, but it will remain the world's most fearsome military power for a very long time. If China behaves as though America is weak, and seeks to push back its power, a querulous but well-tended relationship could slide into competition and confrontation and bring about a cold-war stand-off or rivalry for influence in neighbouring states. Already, China's tough new attitude is having an effect. America has redoubled its commitment to policing the South China Sea. Japan and South Korea have just announced closer defence co-operation. This does not serve China's interests.

Mr Hu needs to counter rabid anti-Americanism at home by acknowledging the stabilising role the United States plays in the region, from which, indeed, China gets a huge free ride in the form of safe sea lanes and vast supplies of Middle East oil. And he should use his visit to America to reassure Mr Obama that pragmatic engagement still holds. He needs to show the world an open, confident face of a rising China. And though Communist leaders don't “do” apologies, Mr Hu must persuade the world that a prickly year has been an aberration.