By Ben Blanchard and Michael Martina

BEIJING (Reuters) - China criticized North Korea's nuclear test on Friday but Beijing is unlikely to follow up with strong action because its influence is limited and it believes the United States and South Korea share responsibility for growing tensions in the region.

China, Pyongyang's main diplomatic ally, is key in any effort to rein in North Korea's nuclear program. But it has been infuriated by the isolated nation's nuclear and missile tests and has signed up to increasingly tough United Nations sanctions.

Foreign ministry spokeswoman Hua Chunying said China would lodge a diplomatic protest with North Korea at its embassy in Beijing for conducting the test.

Beijing has also repeatedly expressed anger since the United States and South Korea decided in July to deploy the Terminal High Altitude Area Defence (THAAD) anti-missile system in the South to counter missile and nuclear threats from North Korea.

China says this is a threat to its own security and will do nothing to bring North Korea back to the negotiating table on its nuclear program.

China's official Xinhua news agency, in a commentary after North Korea confirmed the test, said it was shocking and unwise and would only "add oil to the flames".

But it added that nobody benefited from chaos or war in Korea and all parties in the international community should exercise restraint and avoid doing anything that is "mutually irritating".

"Not long along, South Korea ignored the strong opposition of neighboring countries and decided to deploy the THAAD system, which is diametrically opposed to efforts to maintain peace and stability on the peninsula, has seriously damaged regional strategic balance and caused a rise in tensions on the peninsula."

Previous recent comments from China following North Korean missile tests, including one on Monday when China was hosting the G20 summit, have pointedly not mentioned North Korea by name.

One senior Beijing-based Western official, who has worked in Pyongyang, said China had little influence and no control over North Korea, despite the popular perception in Washington.

Story continues

"The North Koreans don't like the Chinese and certainly don't listen to them," he said, speaking on condition of anonymity.

It's also a misunderstanding to think that the North's youthful leader Kim Jong Un is unhinged, he added.

"The North Korean leadership knows exactly what they are doing and how far they can push things. They know it would be the end of their country if they really provoked a war as the Americans would just flatten them."

ADVANCE WARNING

Michael Madden, an expert on the North Korean leadership, said he was fairly confident that North Korea would have given Russia and China advance warning of the test.

Choe Son Hui, North Korea's negotiator for the stalled talks on Pyongyang's nuclear program, visited Beijing this week, while Yun Tong Hyon, the vice chief of the Ministry of the People's Armed Forces, led a North Korean military delegation to Moscow this week.

"Both would have direct knowledge about a forthcoming test and would be tasked to pass along a heavily implicit message," said Madden.

Hua, the Chinese spokeswoman, said she had no information to provide on whether Beijing received advance warning.

She would also not be drawn on whether China would support further sanctions, saying only that it has fulfilled previous U.N. resolutions and would continue to take a responsible and constructive attitude toward talks at the Security Council.

Another Beijing-based diplomatic source said the level of Beijing's anger with South Korea could be seen with what he termed as the unusually strong public comments about THAAD by President Xi Jinping when he met South Korea's president this week on the sidelines of the G20 summit.

"Mishandling the issue is not conducive to strategic stability in the region and could intensify disputes," Xi was quoted by China's Foreign Ministry as saying.

The diplomatic source said it was not expected that China would publicize such comments. "China blames South Korea and the United States just as much as it does North Korea for the current state of tensions," the source said.

To be sure, there is little public sympathy in China for Kim, who is derisively referred to on Chinese social media as "Fatty Kim the Third" after his father and grandfather.

On Friday, China's Twitter-like Weibo service blocked searches for that term, although there were still plenty of comments condemning him.

"Fatty the Third has gone crazy," wrote one user.

China is also upset with the United States for what it sees as Washington's interference in the disputed South China Sea.

Jin Qiangyi, Director of Yanbian University's Centre for North and South Korea Studies on the Chinese side of the North Korea border, said China would be in a quandary about a substantive reaction.

"We can't completely not cooperate with the United States, but we can't completely be at their beck and call," Jin said, pointing to the South China Sea as an issue that China is unhappy with the United States about.

Still, China's options are limited for a country already under tough sanctions which in any case does little trade with the outside world.

"If North Korea does not listen, of course we can try pressure, to use sanctions to resolve things," Jin said. "But if that does not work what then? Is there anything else we can do? The answer is no."

(Additional reporting by Beijing newsroom, and James Pearson in Seoul; Editing by Raju Gopalakrishnan and Clarence Fernandez)