By Dan Griffiths
BBC News, Beijing
China's suspicion of North Korea is growing
A North Korean nuclear test has long been a nightmare scenario for China.
Beijing is one of the North's few remaining allies, and a major supplier of energy and financial aid to the secretive regime in Pyongyang.
China wants stability on the Korean peninsula; the last thing it wanted was an international crisis right on its doorstep.
It has condemned the claimed test on Monday, saying it resolutely opposes North Korea's actions, and that the test has damaged relations between the two countries.
That anger is also mixed with embarrassment, because Beijing repeatedly urged the North Koreans to abandon their plans for a test.
The fact that the North went ahead regardless appears to be an indication that there are limits to the influence that China's leaders have in Pyongyang.
But the situation is more complex than that. China fears that if it uses what leverage it does have, by stopping aid to North Korea, the regime in Pyongyang might collapse.
That could send a flood of refugees over the border into China - something that Beijing wants to avoid at all costs.
So China is reluctant to use the powers it has, worrying about the possible consequences of pulling the plug on Pyongyang.
The resultant limits to what Beijing can achieve were demonstrated earlier this year, when North Korea carried out a series of missile tests despite Chinese pleas not to go ahead.
Beijing condemned the tests and approved a UN Security Council resolution imposing weapons-related sanctions on North Korea.
But despite international pressure, it did not cut aid to North Korea, preferring to work through multi-national institutions.
China has repeatedly urged North Korea to return to the six-nation disarmament talks involving the two Koreas, Japan, China, Russia and the US.
But those discussions broke down last year, and the nuclear test means any speedy resumption is unlikely.
That leaves many observers wondering how China will respond this time.
Beijing has already said that the UN Security Council must take what it has called "appropriate action" against North Korea.
So far, though, China says it is still considering what exactly that response should be.
There is little doubt that Beijing will be in regular contact with other countries in the region - especially South Korea and Japan - as well as the US.
They will be working together on a unified response to the test, that will then go to the UN Security Council.
There's likely to be considerable negotiating in the days ahead, as the various countries involved try to reach a resolution that will be acceptable to everyone.
In the past China has always opposed tough international action against North Korea.
But there is no doubt that Beijing is extremely angry about this nuclear test - and Pyongyang may be about to find out that there are limits to China's patience.