Donald Trump says the US will maintain "maximum sanctions and pressure" on North Korea, despite being told by Xi Jinping that the Chinese leader's meeting with Kim Jong-un "went very well".

"For years and through many administrations, everyone said that peace and the denuclearization of the Korean Peninsula was not even a small possibility," the US president wrote on Twitter.

"Now there is a good chance that Kim Jong Un will do what is right for his people and for humanity. Look forward to our meeting!"

Mr Trump was responding to events in Beijing, which saw the North Korean dictator make his first known trip outside the country since taking power in 2011.

The confirmation of the visit, which saw Mr Kim discuss the possibility of denuclearisation on the Korean peninsula, capped days of speculation after an armoured train was spotted arriving in the Chinese capital.

"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," Mr Trump wrote. "In the meantime, and unfortunately, maximum sanctions and pressure must be maintained at all cost!"

Accompanied by his wife, greeted by honour guards, and entertained at banquets, Mr Kim was wined and dined in the capital of the world's most populous country.

Despite recent chilly relations between the neighbours, the Chinese president rolled out an actual red carpet for Kim, who arrived from Pyongyang in a 21-car bulletproof train.

Mr Kim's trip appears to be part of a diplomatic offensive that has seen him propose upcoming summits with South Korean president Moon Jae-in and Mr Trump.

Until recently the US and North Korea were engaged in an escalating war or words over Pyongyang's continued development of nuclear weapons with the capacity to strike anywhere on American soil.

In September, Mr Kim branded Mr Trump a "mentally deranged dotard", while in January the US president warned the communist leader his "nuclear button" was "much bigger and power powerful" than his.

But a recent thawing in relations has seen tentative agreements put in place for a meeting between the two unpredictable leaders.

In line with the previous three visits by Mr Kim's father to China, the Chinese government described the trip as unofficial, with no North Korean flags hung around Beijing's Tiananmen Square as happens with state visits.

Donald Trump says he 'believes' North Korea leader Kim Jong Un about peace talks

But Chinese state television gave similar coverage to Mr Kim's meetings with Mr Xi as they did to Mr Xi's meetings with Mr Trump last year, with an unusually long 14-minute report of what Mr Xi and Mr Kim discussed and where and how they met, though the initial secrecy of the trip meant no live coverage of the welcome ceremony.

The images showed the two men chatting in a friendly way, and Mr Xi's wife Peng Liyuan also greeting Mr Kim's wife, Ri Sol-ju. Mr Kim and Ms Ri were shown waving out of a window as their car drew away.

In making the trip to Beijing in the customised train, Mr Kim sought to highlight his place as the heir to his father Kim Jong-il, said Aidan Foster-Carter, an honorary senior research fellow at Britain's Leeds University. His father had also gone to China by train on his visits.

"Ordinary mortals just take the plane," he said. "The train sets the precedent of following in daddy's footsteps."

But by making his wife a key figure in the Beijing trip, Mr Kim parted from his father's behaviour and mirrored the ways of today's modern country leaders.

North Korea Military Parade Show all 6 1 /6 North Korea Military Parade North Korea Military Parade In this image made from video released by KRT on Feb. 8, 2018, a military parade is held at Kim Il Sung Square in Pyongyang, Thursday, Feb. 8 2018, just one day before South Korea holds the opening ceremony for the Pyeongchang Winter Olympics. (KRT via AP Photo) AP North Korea Military Parade This screen grab taken from North Korea's KCTV on February 8, 2018 shows members of North Korea's military taking part in a parade, with missiles being displayed, in Kim Il Sung Square in Pyongyang. North Korea staged a military parade in Pyongyang on February 8 to mark the 70th anniversary of its armed forces, in a show of strength just a day before the Pyeongchang 2018 Winter Olympic Games open in the South. / AFP PHOTO / KCTV / KCTV / -----EDITORS NOTE --- RESTRICTED TO EDITORIAL USE - MANDATORY CREDIT "AFP PHOTO / KCTV" - NO MARKETING - NO ADVERTISING CAMPAIGNS - DISTRIBUTED AS A SERVICE TO CLIENTS - NO ARCHIVESKCTV/AFP/Getty Images AFP/Getty Images North Korea Military Parade In this image made from video released by KRT, North Korean soldiers march during a military parade in Pyongyang, Thursday, Feb. 8 2018. North Korea held a military parade and rally on Kim Il Sung Square on Thursday, just one day before South Korea holds the opening ceremony for the Pyeongchang Winter Olympics. (KRT via AP Photo) AP North Korea Military Parade In this image made from video released by KRT on Feb. 8, 2018, North Korean leader Kim Jong Un, right, inspects honor guards, along with his wife Ri Sol Ju, center, during a military parade in Pyongyang, Thursday, Feb. 8 2018. North Korea held a military parade and rally on Kim Il Sung Square on Thursday, just one day before South Korea holds the opening ceremony for the Pyeongchang Winter Olympics. (KRT via AP Photo) AP North Korea Military Parade In this image made from video released by KRT on Feb. 8, 2018, North Korean leader Kim Jong Un, center, watches the military parade in Pyongyang, Thursday, Feb. 8 2018. North Korea held a military parade and rally on Kim Il Sung Square on Thursday, just one day before South Korea holds the opening ceremony for the Pyeongchang Winter Olympics. (KRT via AP Photo) AP North Korea Military Parade This screen grab taken from North Korea's KCTV on February 8, 2018 shows North Korean leader Kim Jong Un speaking during a military parade in Kim Il Sung Square in Pyongyang. North Korea staged a military parade in Pyongyang on February 8 to mark the 70th anniversary of its armed forces, in a show of strength just a day before the Pyeongchang 2018 Winter Olympic Games open in the South. / AFP PHOTO / KCTV / KCTV / -----EDITORS NOTE --- RESTRICTED TO EDITORIAL USE - MANDATORY CREDIT "AFP PHOTO / KCTV" - NO MARKETING - NO ADVERTISING CAMPAIGNS - DISTRIBUTED AS A SERVICE TO CLIENTS - NO ARCHIVESKCTV/AFP/Getty Images AFP/Getty Images

Kim Jong Il had never been seen abroad with any of his wives, though he was believed to have been accompanied by the woman suspected of being his fourth wife on visits to China and Russia, yet it was never announced officially.

"Unlike his father, Kim Jong Un presented Ri Sol Ju as first lady of North Korea, emphasising her status and portraying his image as a normal leader," said Kim Yong-hyun, professor of North Korean studies at South Korea's Dongguk University. "It appears to be a well-calculated tactic that would help turn Kim's hostile and unfavourable image to a gentle and sane one."

As the leader of a country often called reclusive and strange, Mr Kim is also much younger than many world leaders, a difference that gets additional resonance in Asia, where respectful deference to elders is widely upheld.

Estimated to be 34, Mr Kim is decades younger than 64-year-old Xi, 65-year-old Moon, and Mr Trump, who is 71.

Frosty relations between Beijing and Pyongyang since Mr Kim took office had seen state-to-state relations deteriorate, but the two sides have always maintained party-to-party ceremonies and traditions, such as sending envoys to share the outcomes of key party meetings, according to diplomats.

Mr Kim officially cast his visit in the same light, saying he felt obligated to come congratulate Mr Xi in person on his recent re-appointment as president, according to the Chinese foreign ministry's account of the trip.

China's most senior party diplomat, politburo member Yang Jiechi, attended the main meeting between Mr Xi and Mr Kim, along with Wang Huning, the party's top theoretician. The government's top diplomat, State Councillor Wang Yi, was also there, though at the far end of the table.

From the North, Mr Kim brought with him the country's most high-profile officials, including vice chairman of the Workers' Party central committee Choe Ryong-hae, politburo member Ri Su-yong, foreign minister Ri Yong-ho, and Kim Yong-chol, a former intelligence chief who now handles inter-Korean affairs.

Taking nearly all of his closest aides highlights the confidence he may be feeling now that he has secured his position, showing that he does not fear there could be a coup against him during his time away, said Yang Moo-jin, professor at the University of North Korean Studies in Seoul.

"We saw many high-ranking officials with Kim, but almost none from the military. One could worry about a military coup, but the fact that he made this trip as he did shows he's completely in charge of the military as well as all of North Korea's internal networks," Mr Yang said.