BEIJING (Reuters) - China will not allow chaos and war to break out on the Korean peninsula, which would be to no one’s advantage, Chinese President Xi Jinping told a group of Asian foreign ministers on Thursday.

China's President Xi Jinping is photographed by a smartphone at the opening ceremony of the fifth regular foreign ministers' meeting of the Conference on Interaction and Confidence Building Measures in Asia (CICA) at the Diaoyutai State Guesthouse in Beijing Apr28, 2016. REUTERS/KYODO NEWS/IORI SAGISAWA/POOL

North Korea’s drive to develop a nuclear weapons capability, in defiance of U.N. resolutions, has angered China and raised tension in the region.

“As a close neighbor of the peninsula, we will absolutely not permit war or chaos on the peninsula. This situation would not benefit anyone,” Xi said in a speech to a Conference on Interaction and Confidence Building Measures in Asia.

On Thursday, South Korea’s defense ministry said North Korea had fired what appeared to have been an intermediate range ballistic missile that crashed within seconds of the test launch.

It was the second such failure in the run-up to next week’s

ruling party congress in Pyongyang, and follows the isolated state’s fourth nuclear test in January.

North Korea is expected to conduct another nuclear test before the rare congress, set to begin on May 6, at which young leader Kim Jong Un is expected to try to cement his leadership.

China is North Korea’s sole major ally but it disapproves of its development of nuclear weapons and backed harsh new U.N. sanctions imposed against North Korea last month.

China has long called for the Korean peninsula to be free of nuclear weapons.

Nearly 30,000 U.S. troops are based in South Korea and the two Koreas are still technically at war after the 1950-53 conflict ended in an armistice, not a treaty.

Xi also told the meeting China would safeguard peace and stability in the South China Sea, while at the same time maintaining its sovereignty and rights there.

China claims almost the entire South China Sea, believed to rich in oil and gas deposits. Brunei, Malaysia, the Philippines, Taiwan and Vietnam also claim parts of the waters, through which about $5 trillion in trade is shipped every year.

China has rattled nerves with its military and construction activities on tiny islands in the disputed waters, including building runways, though it says most of it is for civilian purposes.

Chinese officials say the United States is pushing militarization and endangering stability with “freedom of navigation” operations by its military in the South and East China seas.

The U.S. operations were “extremely dangerous” political and military provocations that could lead to maritime mishaps, said Chinese Defense Ministry spokesman Wu Qian.

“Freedom of navigation has become an excuse for the United States to meddle in South China Sea disputes,” Wu told a regular news briefing.

The United States calls its patrols an effort to demonstrate that the international community does not accept restrictions set up by some countries in international waters.

The 26-member conference on confidence building measures in Asia includes Russia and many central Asian and Middle Eastern nations. The United States and Japan are among eight observers.