Beijing has confirmed that North Korean leader Kim Jong Un has visited China to hold talks with President Xi Jinping, in his first foreign visit since taking power.

The announcement corroborated speculation which was sparked when a train similar to the one the dictator's father used was spotted making a round-trip to Beijing.

Xi held talks with Kim at the Great Hall of the People in Beijing and he and his wife Peng Liyuan hosted a banquet for Kim and his wife Ri Sol Ju.

'I have had successful talks with General Secretary Xi Jinping on developing relations between the two parties and the two countries, our respective domestic situation, maintaining peace and stability on the Korean Peninsula, and other issues,' Kim said at the banquet.

Kim also committed to denuclearisation in Korea if the United States and the South showed 'goodwill', it was reported, with China agreeing to support its neighbour if nuclear tensions could be eased.

Scroll down for video

Beijing has confirmed that North Korean leader Kim Jong Un has visited China to hold talks with President Xi Jinping, his first foreign visit since taking power

Kim visited China from Sunday to Wednesday with his wife, Ri Sol Ju, where they held talks and a banquet while Kim said he was willing to talk to the United States

Kim Jong Un, left, and his wife Ri Sol Ju wave from a car as they bid farewell to President Xi and his wife, Ri Sol Ju

During the visit from Sunday to Wednesday, Kim held talks with Xi Jinping in Beijing, where the Chinese president hosted a banquet to welcome the North Korean leader

Kim Jong Un told Chinese President Xi Jinping that it was his 'solemn duty' to make Beijing his first overseas destination as he made his maiden foreign trip as leader

Kim Jong-un, sat alongside his wife Ri Sol-ju, speaks to President Xi Jinping in this photo taken on board the train used by Kim to arrive in China

Kim laughs inside crowded carriage as photographers and cameramen clamber around him

Kim visited China from Sunday to Wednesday with his wife, Ri Sol Ju, a South Korean news agency said, with President Xi also accepting an invitation to visit North Korea.

The trip comes weeks after US President Donald Trump accepted an invitation to meet Kim.

Analysts say Kim would have felt a need to consult with his country's traditional ally ahead of his planned meetings with Mr Trump and South Korean President Moon Jae-in.

'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.

In a statement Tuesday night, White House press secretary Sarah Huckabee Sanders said: 'The Chinese government contacted the White House earlier on Tuesday to brief us on Kim Jong Un's visit to Beijing.

'The briefing included a personal message from President Xi to President Trump, which has been conveyed to President Trump.

'The United States remains in close contact with our allies South Korea and Japan.

'We see this development as further evidence that our campaign of maximum pressure is creating the appropriate atmosphere for dialogue with North Korea.'

Kim (right) said he had successful talks with General Secretary Xi Jinping (left) on developing relations between the two parties and the two countries

President Xi and Kim strolled through Beijing together as they did their best to show relations were back on track after a recent chill

Kim and his wife Ri Sol Ju, visit an exhibition highlighting achievements by the Chinese Academy of Sciences

Kim signs a message during his trip to Beijing, which was only recently confirmed by China

Kim Jong-un waves from the window of his personal train during his whirlwind visit to China

North Korean leader Kim Jong Un was accompanied by his wife Ri Sol Ju for the unofficial visit

Mr Kim made the unofficial visit to China from Sunday to Wednesday at Mr Xi's invitation, China's official Xinhua News Agency said

Kim told Xi that it was his 'solemn duty' to make Beijing his first overseas destination as he made his maiden foreign trip as leader, Pyongyang's official news agency reported.

Beijing has traditionally been the closest ally of secretive North Korea, but ties have been frayed by North Korea's pursuit of nuclear weapons and China's backing of tough U.N. sanctions in response.

Xi hailed Kim's visit as embodying the importance with which the North Korean leader regarded ties with China.

'We speak highly of this visit,' Xi told Kim, according to Xinhua.

At a banquet in Beijing Kim said: 'There is no question that my first foreign visit is to the Chinese capital,' KCNA reported.

Bottoms up: The two leaders enjoyed a glass of wine as they met in Beijing this week

It was all smiles as the North Korean dictator sat down for a banquet during his visit to China

The leaders sought to portray strong ties between the long-time allies despite a recent chill as both countries confirmed Mr Kim's secret trip this week

North Korean leader Kim Jong Un and his wife Ri Sol Ju pose for pictures alongside Chinese President Xi Jinping and his wife Peng Liyuan

North Korean leader Kim Jong Un and his wife Ri Sol Ju are pictured visiting the Chinese Academy of Sciences

'This is my solemn duty as someone who should value and continue the DPRK-PRC relations through generations,' he added using the countries' official acronyms.

Kim confirmed that his nuclear-armed regime was willing to hold a summit with Washington, Xinhua said.

'The DPRK is willing to have dialogue with the United States and hold a summit of the two countries,' Kim reportedly said.

'It is our consistent stand to be committed to denuclearisation on the peninsula, in accordance with the will of late President Kim Il Sung and late General Secretary Kim Jong Il,' he said.

'The issue of denuclearisation 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 realisation of peace.'

A dark green train (pictured), believed to be carrying a senior North Korean delegation, left the Chinese capital on Tuesday following a dramatic whirlwind visit

Earlier, a motorcade of blacked out cars had been seen entering Beijing Railway Station. The meeting between the leaders of China and North Korea was later confirmed

President Xi said: 'Both Comrade Chairman and I have personally experienced and witnessed the development of China-DPRK relationship.

'This is a strategic choice and the only right choice both sides have made based on history and reality.... This should not and will not change because of any single event at a particular time,' Xi said.

The visit to China marks Kim's first known trip since taking power in 2011 and his reported meeting with Xi was his first meeting with a foreign head of state.

Kim's father, late North Korean leader Kim Jong Il, visited China several times during his rule, for the final time in May 2011, months before his death.

Past visits by Kim Jong Il to China were surrounded in secrecy, with Beijing only confirming his presence after he had crossed the border by train back into North Korea.

A limousine without car plates and bearing a gold color emblem on its side arrives amid heavy security at the train station in Beijing

A senior U.S. official said the available evidence suggested that Kim had travelled to Beijing to meet Chinese President Xi Jinping. Beijing later confirmed the meeting

Earlier, a motorcade of blacked out cars had been seen entering Beijing Railway Station while a foreign guesthouse in Beijing had a heavy security presence overnight.

The visit came ahead of planned summit meetings with Mr Trump and South Korean President Moon Jae-in.

Improving ties between North Korea, which is pursuing nuclear and missile programmes in defiance of U.N. Security Council resolutions, and China would be a positive sign before the planned summits, an official in Seoul said.

A Reuters reporter saw a convoy leave Beijing's Diaoyutai State Guest House, where senior foreign leaders often stay, and drive north on Tuesday morning. It was unclear where the convoy was headed.

Later, a journalist saw what was believed to be the delegation's train pulling out of a Beijing station. The group was reported to have arrived in China on Sunday after crossing from North Korea in the border city of Dandong.

The dark green train bears a distinctive yellow stripe down the side and looks the same as one used by Kim Jong-il in the past

There was a heavy police presence as a motorcade travelled along hang'an Avenue, a major east-west thoroughfare in Beijing

The news of the meeting came amid talk of preparations for a meeting between the North's reclusive leader and President Donald Trump

Xi and Kim Jong Un had reasons to meet in advance of Kim's meetings with Moon and possibly Trump, a U.S. official said.

'Xi has met Trump, and in many respects learned how to deal with him better than some people here do,' the official said.

'At the same time, despite the recent tensions, he needs to know what Kim has in mind for dealing with the South and the U.S., and he still has a lot of leverage with the North.'

Beijing is the main ally of secretive and isolated North Korea, as well as its biggest trading partner.

The rail journey between Dandong and Beijing covers more than 680 miles. It takes at least 14 hours by ordinary service, according to Chinese railway timetables.

A South Korean in Seoul watches a television news report about a visit to China by North Korean leader Kim Jong Un

Police in tactical gear block a road leading to the Diaoyutai State Guesthouse in Beijing amid reports Kim Jong-un was in town, which were later confirmed

The train appeared to be the same one that was used by Kim Jong-il to visit China multiple times in the past (pictured here in 2011)

Kim Jong-il pictured visiting China on board a North Korean armoured train in 2001

The North Korean leader is due to hold separate summits with South Korea in late April and the United States in May.

'The fact that the summits are being held has been beyond our expectations. Right now, the situation surrounding the Korean peninsula is moving very quickly and it would be inadvisable to think with prejudice,' a Blue House official said.

Kim Jong Un's father, Kim Jong Il, met then-president Jiang Zemin in China in 2000 before a summit between the two Koreas in June that year.

Kim Jong Il was considered at the time to have made the visit to reaffirm close ties with China.

'North Korea likely wants to confirm its relationship with China and believes it has some leverage with which it can ask for things from China,' said Yoo Ho-yeol, Professor of North Korean studies at Seoul's Korea University.

'If North Korea speaks with the United States on its own, it might feel it is at a disadvantage but, if it has China as an ally, Pyongyang may think it will be able to protect its interests and profits during the summits.'