North Korean leader Kim Jong Un has left Beijing, ending a trip to China seen as preparation for his expected summit with US President Donald Trump later this year.

Kim arrived in the Chinese capital on Tuesday for his fourth visit to Pyongyang's key ally, reportedly visiting a factory and meeting President Xi Jinping.

The North Korean leader's motorcade was spotted arriving at the Beijing central railway station early on Wednesday afternoon, and Kim's train departed shortly after for the day-long ride back to the border, according to news agencies.

The unannounced trip was largely shrouded in secrecy. Beyond confirming Kim's presence in Beijing, neither North Korea or China provided any details on the visit.

Kim spent one hour with Xi on Tuesday - believed to be the North Korean leader's birthday - and the two later dined with their wives at Beijing's Great Hall of the People, according to South Korea's Yonhap news agency.

The discussions focused on Kim's expected meeting with Trump, Yonhap said.

In a New Year speech, Kim warned that Pyongyang may change its approach to nuclear talks if Washington persists with sanctions.

Relations between China and North Korea had deteriorated in recent years over Pyongyang's nuclear activities, but Kim has made sure to keep Xi informed about his dealings with the US and South Korea as ties appear to have warmed.

"In order to resist the high pressure of the US, he must communicate with Xi in advance to see what steps he can take to deal with Trump," Beijing-based independent political commentator Hua Po told the AFP news agency.

"Kim needs the support of Xi so as to ask the US to make substantial steps, such as providing assistance to North Korea and normalising relations with North Korea," Hua said.

Kim chose China for his maiden official trip abroad last year before holding meetings with South Korean President Moon Jae-in and Trump.

Trump said on Sunday that the US and North Korea are negotiating the location for their next summit.

Discussions between the US and North Korea over Pyongyang's nuclear arsenal have stalled since Kim and Trump's high-profile summit in Singapore in June where they issued a vaguely-worded declaration about denuclearisation.

The US insists that United Nations sanctions must remain in place until North Korea gives up its weapons, while Pyongyang wants them eased immediately. China also wants the sanctions to be relaxed.

"For North Korea itself, 2019 is his strategic turning point. If he wants to shift his focus to the development of the economy, he needs China's cooperation," said Lu Chao, a North Korea expert at China's Liaoning Academy of Social Sciences.

"China will also introduce some successful experiences to Kim to help North Korea achieve economic transformation and realise the denuclearisation of the peninsula as soon as possible," Lu added.

In his New Year speech, Kim focussed on his country's economy, saying that improving people's lives was his top priority and tackling energy shortages was an urgent task.

The visit coincided with negotiations between US and Chinese officials in Beijing to resolve a bruising trade war between the world's two biggest economies.

Some analysts say China could use its cooperation on North Korea as a bargaining chip in the US trade talks.

But Hua said Kim's visit would have a "limited" effect on the trade negotiations.

"The Sino-US trade negotiations are a matter between China and the US. The weight of North Korea is limited and cannot play a decisive role," he said.