Foreign Minister Wang Yi met Afghan President Ashraf Ghani in Kabul and said a three-way conference mechanism involving the two countries and China could promote dialogue and cooperation, the ministry said in a statement on its website.
"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."
Wang was visiting Pakistan on the weekend.
Neither Afghan nor Pakistani officials were available for comment.
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 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 separatist group with links to militants in South Asia.
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.
The state-run China Metallurgical Group Corp won a contract to develop Afghanistan's Mes Aynak copper mine in 2007 but the project has been mired in delays.