Beijing (CNN) North Korean leader Kim Jong Un has made his first foreign trip since assuming power in 2011, meeting China's President Xi Jinping in Beijing and discussing giving up the country's nuclear weapons, according to Chinese state media.

Kim, who made the surprise trip to the Chinese capital at Beijing's request, said he felt compelled to personally inform President Xi of the rapid diplomatic developments on the Korean Peninsula in recent weeks, Xinhua reported.

The visit represents stunning shift for Kim, who appears to be fashioning himself as a leader in search of a peaceful solution to the crisis on the Korean Peninsula. It's in sharp contrast to 2017, when Kim oversaw a string of missile and nuclear tests that drew the ire of the international community.

Kim's trip was the first of three potential meetings with some of the world's most powerful leaders.

Kim is set to attend a summit with South Korean President Moon Jae-in next month, and will later meet US President Donald Trump, in what would be an historic first encounter between a sitting US President and a North Korean leader.

Trump tweeted Wednesday that Xi told him his meeting with Kim went "very well."

The US President added he was optimistic Kim will "do what is right for his people and for humanity. Look forward to our meeting!"

Received message last night from XI JINPING of China that his meeting with KIM JONG UN went very well and that KIM looks forward to his meeting with me. In the meantime, and unfortunately, maximum sanctions and pressure must be maintained at all cost! — Donald J. Trump (@realDonaldTrump) March 28, 2018

Key points:

Kim said he was committed to denuclearization but with conditions, Xinhua reported

Xi hosted a grand banquet for Kim at the Great Hall of the People

Kim traveled to China by train on March 25 and spent two days in Beijing

North Korean state media said Xi accepted an invitation to visit Pyongyang

White House said it was informed of the meeting Tuesday

In this photo released Wednesday by China's Xinhua News Agency, Chinese President Xi Jinping, fourth from left, and North Korean leader Kim Jong Un, second from right, meet at the Great Hall of the People in Beijing.

Analysts said the visit was a courtesy call aimed at shoring up Pyongyang's ties with China, a traditional ally and major trading partner. Leaders from the two countries haven't met since 2011, with ties souring after Kim purged some of Beijing's allies in North Korea and the isolated nation relentlessly pursued its development of nuclear weapons.

Kim called for a "new era" in bilateral relations in a letter to Xi published by the Korean Central News Agency (KCNA), which also reported that Xi had accepted an invitation to visit North Korea "at a convenient time." The acceptance of the invitation was not reported by Chinese state media although Xinhua said that Xi would keep in frequent contact, which could include exchange of visits.

From left to right: Ri Sol Ju, North Korea's first lady; North Korean leader Kim Jong Un; Chinese President Xi Jinping and his wife, Peng Liuyan.

"In this spring full of happiness and hopes, I believe my first meeting with General Secretary Xi Jinping will yield abundant fruits of DPRK-China friendship, and facilitate peace and stability on the Korean Peninsula," said Kim, referring to Xi by his title as leader of the Chinese Communist Party.

Kim made his trip "at the invitation" of Xi, state media from both countries reported. While billed as an unofficial visit, Kim got red-carpet treatment in Beijing, including a banquet at the Great Hall of the People.

North Korean leader Kim Jong Un and his wife, Ri Sol Ju, (left) wave to Chinese President Xi Jinping and his wife, Peng Liyuan (right) in photos released by North Korean state media.

An equal player?

North Korea's diplomatic charm offensive is likely part of an attempt to show Kim as a world player equal in stature to leaders like Xi, said Jean Lee, an analyst at the Hyundai Motor-Korea Foundation Center for Korean History and Public Policy at The Wilson Center.

"We're seeing a carefully crafted North Korean strategy on diplomacy unfold on the world stage, starting with Beijing," Lee said.

"He's positioned himself as the peacemaker, he's made all the first moves."

Chinese President Xi Jinping (left) and North Korean leader Kim Jong Un (right) are seen together in Beijing in a photograph released by North Korea's state-run Korean Central News Agency.

Chinese state media quoted Kim as saying that he is committed to the denuclearization of the Korean Peninsula, a key Chinese goal, but Lee warned Kim would seek major concessions in exchange for giving up nuclear weapons.

"The issue of denuclearization of the Korean Peninsula can be resolved, if South Korea and the United States respond to our efforts with goodwill, create an atmosphere of peace and stability while taking progressive and synchronous measures for the realization of peace," Kim said, according to Xinhua.

North Korean state media made no mention of nuclear weapons in its coverage of the meeting.

Kim Jong Un and his wife Ri Sol Ju are seen outside what appears to be the Kim's family train car in Beijing in a photograph released by North Korean state media. Kim arrived in China by train on March 25 and crossed the border back to Pyongyang on March 28.

White House credits 'maximum pressure'

Images broadcast on Chinese state television CCTV Wednesday showed Kim and his wife, Ri Sol Ju, meeting with Xi and other Chinese officials during the trip.

Analysis This trip means that Kim is no longer a total novice when it comes to international leaders -- crucial experience before he meets Moon and Trump. If not a seasoned pro, at least he has already met and bonded with arguably the world's most important person -- Xi Jinping. He can also feel that, to a certain extent, China has his back. The price of that is the headline of this visit: Putting the nukes on the table. For China, the visit allows the country to reassert itself as a kingpin in the process, after the optics of a potential Kim/Trump summit catching Beijing by surprise. By the way he received Kim in Beijing, Xi is showing that in spite of its observance of sanctions, and applying pressure, China is not part of an anti-North Korean coalition. Xi also painted a rosy future for North Korea's economy that, without saying it explicitly, is one that can only exist when North Korea has done enough to get sanctions lifted. A carrot that Kim desperately needs. From CNN Beijing bureau chief Tim Schwarz

As well as Xi, Kim also took part in events with his deputies, including Li Keqiang, the Chinese premier, and Wang Qishan, the Chinese vice president who is considered one of Xi's closest confidantes.

The trip took place from March 25 to 28, with Kim and his wife traveling by train. Rumors first surfaced about a potential visit by a high-level North Korean representative Monday night in Beijing , when pictures of what appeared to be the Kim family's distinctive green train surfaced online.

The White House said in a statement that the Chinese government briefed them on the meeting Tuesday and claimed some credit for the development.

"We see this development as further evidence that our campaign of maximum pressure is creating the appropriate atmosphere for dialogue with North Korea," White House press secretary Sarah Sanders said.

The US has spearheaded efforts at the United Nations to sanction North Korea and pressured China to implement measures targeting Pyongyang's ability to import fuel and bring in revenue.

Kim Jong Un, left, and Xi Jinping, right, are seen at a banquet in this photo released by North Korean state media.

Friends again

Xi and his wife, Peng Liyuan, also held a welcome banquet for their visitors. Kim told his hosts that he chose China as his first overseas destination as leader to show "his will to carry forward the tradition of DPRK-China friendship, and how he valued the friendship between the two countries," referring to North Korea by its formal name, the Democratic People's Republic of Korea.

Xi said Beijing is willing to work with North Korea to "promote long-term healthy and stable development of China-DPRK relations, benefit the two countries and two peoples, and make new contribution to regional peace, stability and development," Xi said.

KCNA said Kim was "accorded cordial hospitality with utmost sincerity to him in token of warm comradely friendship and friendly feelings during his China visit."