ISLAMABAD (Reuters) - China’s foreign minister has urged leaders in Afghanistan and Pakistan to improve relations and establish a crisis prevention and management mechanism during visits to both countries, the Chinese foreign ministry said.

Chinese Foreign Minister Wang Yi speaks during a joint news conference with his Jordanian counterpart Ayman Safadi in Amman, Jordan June 22, 2017. REUTERS/Muhammad Hamed

Foreign Minister Wang Yi was scheduled to speak in Islamabad on Sunday, a day after meeting Afghan President Ashraf Ghani in Kabul.

Wang said a three-way conference mechanism involving the two countries and China could promote dialogue and cooperation, the Chinese ministry said in a statement.

“China sincerely wishes for Afghanistan and Pakistan to improve relations, rebuild mutual trust strengthen cooperation, achieve mutual safety and mutually development,” Wang said, according to the statement.

“As Afghanistan and Pakistan’s mutual friend, China encourages them to establish a crisis prevention and management mechanism as soon as possible, to properly deal with any kind of sudden occurrence.”

In Pakistan, Wang “held wide-ranging discussions” on bilateral relations, regional security and the situation in Afghanistan, the Pakistani foreign ministry said in a tweet.

Afghanistan and Pakistan have been uneasy neighbors ever since Pakistan’s independence in 1947.

Their ties have been poisoned in recent years by Afghan accusations that Pakistan is supporting Taliban insurgents fighting the U.S.-backed Kabul in order to limit the influence of its old rival, India, in Afghanistan.

Pakistan denies that and says it wants to see a peaceful, stable Afghanistan.

Several people were killed when Afghanistan and Pakistan border troops exchanged fire for hours in early May. As a result, a major border crossing was closed for more than three weeks.

‘CHINA’S FIGHT’

In his annual Eid al-Fitr message, Afghanistan’s Ghani said he had met Wang and the two had discussed peace and stability and the joint fight against terrorism.

Ghani used the message, marking the end of the holy month of Ramadan, to call on armed opposition groups including the Taliban to join the peace process, if they were genuine Afghans concerned about the loss of innocent lives.

China is also worried about the spread of Islamist militancy from lawless ethnic Pashtun lands along Pakistan’s border with Afghanistan, in particular the danger of members of its Uighur Muslim minority being radicalized there.

In Pakistan on Saturday, Wang said counter-terrorism was an important part of China’s relations with Pakistan and he thanked Pakistan “for its firm support for China’s fight against the violent terrorist group the ‘East Turkistan Islamic Movement’,” China’s Xinhua news agency reported.

China says the East Turkistan Islamic Movement is a violent Uighur group, with links to militants in South Asia, who want to make the far western region of Xinjiang a separate state.

Uighur exiles and rights groups though say unrest in Xinjiang is more a reaction to repressive government policies than the plotting of any cohesive militant group. Beijing denies abusing rights in Xinjiang.

China is also investing heavily in both Afghanistan and Pakistan.

It has promised $57 billion in investment in projects along a China-Pakistan Economic Corridor, part of its ambitious Belt and Road plan linking China with the Middle East and Europe.