BEIJING — North Korea’s enigmatic young leader, Kim Jong-un, made an unannounced visit to Beijing, meeting with President Xi Jinping weeks before planned summit meetings with American and South Korean leaders, Chinese and North Korean state news media reported on Wednesday.

The visit amounted to Mr. Kim’s international debut: It was the 34-year-old leader’s first trip outside North Korea since he took power in 2011, and his first meeting with another head of state. The surprise discussions added another layer of complexity to the rush of global diplomacy around North Korea’s nuclear weapons program.

Mr. Kim told the Chinese leader that he was open to dialogue with the United States, including a potential summit meeting with President Trump, and was committed to the denuclearization of the Korean Peninsula, according to an account published by China’s news agency Xinhua.

“If South Korea and the United States respond with good will to our efforts and create an atmosphere of peace and stability, and take phased, synchronized measures to achieve peace, the issue of the denuclearization of the peninsula can reach resolution,” Mr. Kim said, according to Xinhua’s summary of his meeting with Mr. Xi.