Image copyright AFP Image caption The two leaders have never met in North Korea before

China's President Xi Jinping has met North Korean leader Kim Jong-un during the first Chinese state visit to Pyongyang in 14 years.

The leaders were expected to discuss economic issues and the stalled talks over North Korea's nuclear programme.

It was their fifth meeting in 15 months, but the first to have taken place in North Korea.

Both leaders are currently in separate disputes with the US - China over trade and North Korea over nuclear weapons.

Thursday's meeting was the first between the two leaders since a summit held by Mr Kim and US President Donald Trump ended in February without any agreement on denuclearisation. It also comes just a week before Mr Xi is set to meet the US president at the G20 summit in Japan.

Thousands of people lined the streets to welcome the Chinese president to the country on Thursday morning, with video footage shared by Chinese state media showing crowds waving flowers and banners as his motorcade passed through Pyongyang.

Image copyright AFP Image caption People lined the streets to welcome the Chinese president

The leaders then held talks, in which Mr Xi praised Pyongyang's efforts towards denuclearisation and said he hoped that North Korea and the US could keep talking and make progress, according to Chinese media reports.

Why is the visit happening now?

Mr Xi's two-day visit is the first by any Chinese leader to North Korea in 14 years and his first since taking power in 2012.

It is being seen as a boost for Mr Kim, who has been struggling to maintain momentum after a flurry of diplomatic activity over the past year.

The two leaders will inevitably discuss the stalled nuclear negotiations and the collapse of the Hanoi summit.

Analysts say Mr Xi will want to know what happened and whether any way can be found to move things forward, information he could then share with Mr Trump in Japan.

Image copyright AFP/KCNA VIA KNS Image caption China wants North Korea to stop missile testing

Although the visit was confirmed only earlier this week, Jenny Town, managing editor of US-based analysis site 38 North, says it is not a huge surprise that it is happening now, with the 70th anniversary of the two countries establishing diplomatic ties approaching.

She says there might be some "symbolic value" in the visiting taking place just before the G20 summit, but that it's "more of a bonus than a deciding factor".

What does China want?

China's main goal is stability in North Korea and economic co-operation, and ensuring that it remains a significant party in the negotiations over North Korea's nuclear programme.

The two communist-led states are old allies. But ties have been strained over the past decade, with Pyongyang's nuclear ambitions viewed critically by Beijing.

Image copyright AFP Image caption In June 2018, Kim Jong-un and Donald Trump met for the first time

The official China Daily newspaper said on Wednesday that the visit would allow the two leaders to "agree on some concrete co-operation projects".

And in a rare front page editorial in North Korea's Rodong Sinmun newspaper on Wednesday, Mr Xi reiterated his support for nuclear talks, saying: "China supports North Korea for maintaining the right direction in resolving the issue of the Korean peninsula politically."

What does North Korea want?

The visit will enable Mr Kim to show that he still has China's support, as other relationships are struggling.

"The North Koreans want to keep their friends close even if there isn't a lot of trust and a lot of goodwill between them," says Ms Town.

Media playback is unsupported on your device Media caption North Korea has been called out for evading UN sanctions

North Korea's economy is struggling under the international sanctions regime, put in place because of its repeated nuclear and missile tests.

China, its biggest trading partner, has backed those sanctions but has indicated it would be in favour of some sanctions relief as an incentive for North Korea to denuclearise.

"China has proved to be the main destination for most of North Korea's exports, including minerals, fish, textiles, and also workers," North Korea analyst Peter Ward told the BBC.

Beijing traditionally is also the main importer of goods for North Korea's industry and households. Under current sanctions, a lot of this trade has come to a halt.

"China would prefer to relax UN sanctions in these areas," Mr Ward says. "It wants to ensure that North Korea's economy grows at a fair pace and that the North does not feel the need to test ballistic missiles and/or nuclear weapons again."

Given that sanctions are not likely to get lifted, there is little China can do.

But Kim Hyun-wook, a professor at the Korea National Diplomatic Academy, told Reuters that Chinese economic support - possibly even China creating a "hole" in sanctions - would mean Mr Kim "doesn't have to negotiate with the US from a position of weakness".

"It can have both nuclear weapons and economic aid from China," he said.