China’s top diplomat expressed support for a formal end to the state of war on the Korean Peninsula in a rare meeting Thursday with North Korean leader Kim Jong Un in Pyongyang.

During his two-day visit to the North, Chinese foreign minister Wang Yi said Beijing was in favour of peace efforts between Seoul and Pyongyang, who have remained technically at war since the 1950s.

The North and South agreed last week to work towards a permanent treaty to replace a 65-year-old armistice agreement at a landmark inter-Korean summit, in the latest glimmer of rapprochement between the nuclear armed state and its neighbours.

“China supports ending the state of war on the peninsula,” China’s foreign ministry quoted Wang as saying in a statement.

Beijing “supports North Korea’s strategic focus on economic development and supports the North in resolving its legitimate safety concerns in the process of denuclearisation,” said Wang, according to the statement.

Kim reiterated his commitment to denuclearisation during the talks with Wang, according to China’s account of the meeting.

The visit precedes a planned meeting between Kim and US President Donald Trump in the coming weeks.

Wang is the first Chinese foreign minister to visit the North since 2007, a lapse that highlights the rough patch in relations between the allies in recent years.

China — North Korea’s only major ally and economic benefactor — has supported a series of United Nations sanctions against Pyongyang over its nuclear and missile programmes.

Last year the North staged its most powerful nuclear test to date and launched missiles capable of reaching the US mainland as Kim and Trump traded threats of war and personal insults, sparking global security fears.

But early this year Kim suggested opening diplomatic channels, changing the global calculus and bringing about new hopes for peace, enhanced by a meeting between the North’s leader and his counterpart President Moon Jae-in last Friday.

“North Korea is willing to restore mutual dialogue and establish mutual trust and explore the root causes of the threat to peace in the peninsula,” Kim said, according to China’s statement.

Experts say China is now likely eager to avoid being marginalised in the wave of diplomacy.

In the North Korean leader’s first overseas trip in office, Kim met Chinese President Xi Jinping in Beijing in March.

He has also invited Xi to visit Pyongyang but no date has been set for the trip.