Geopolitical maneuvering, political disunity, endemic corruption, rudderless security apparatus and, most importantly, a confident Taliban movement supported by the Pakistani “deep state” make Afghanistan the most persistent trouble spot. Recent events in the country are dominated by increasing terrorist attacks against security forces and hapless citizens.

Chinese foreign minister Wang Yi visited Kabul and Islamabad June 24-25, in a bid to reduce tension between Afghanistan and Pakistan, one of the toughest regional diplomatic challenges. While regional stability is a main prerequisite for realizing the “China dream” of grand international connectivity projects, restoring peace in Afghanistan is equally critical for China’s own security.

China’s current strategic interests in Afghanistan are tied to the negative outcomes the country wants to avoid. For Beijing, these undesirable outcomes include Afghanistan becoming a safe haven for Uighur radical groups, Islamic forces exerting ideological influence in Xinjiang, and insecurity in Afghanistan further destabilizing Pakistan and other Central Asian republics. These outcomes could diminish the prospects of international projects like “One Belt, One Road” (OBOR) and the China-Pakistan Economic Corridor (CPEC). Beijing is also wary that proxy battles in Afghanistan between India and Pakistan could escalate tensions in South Asia.

Yet Chinese moves have not occurred in a vacuum. Until recently, the Chinese role in Afghanistan has not been as visible and assertive as one would expect from an aspiring global power. It has avoided being sucked into the Afghan political quagmire, despite Beijing’s security interests being seriously affected by it. However, circumstances now seem more favorable for Chinese action. Despite multiple measures and several reconciliation efforts, including the U.S.-led Quadrilateral Coordination Group and Russian-led Moscow talks, peace in Afghanistan remains as elusive as ever. After a long and fruitless wait, China has taken a bold diplomatic step.

Wang’s mission marks a significant shift in China’s Afghan policy, as it is likely to create an opportunity for Beijing to exercise greater influence over the region’s geopolitical context. China’s growing political and diplomatic profile in the global arena requires it to assume a more assertive role in resolving regional disputes. Afghanistan is a test case for China, since the situation involves diverse conflict dynamics with both regional and global implications. Thus, Beijing has sought to change the diplomatic modus operandi, clearly implying that China must act as a real “problem solver,” rather than just serving as a “channel of communication.”

With active Chinese involvement, a bilateral Kabul-Islamabad “crisis management mechanism” has been devised, along with the establishment of a trilateral “dialogue mechanism” at the foreign minister level in order to “cooperate on issues of mutual interest, beginning with economic cooperation.” China has one vital advantage that other mediators, including the United States and Russia, lack. The nation enjoys a rock solid partnership with Pakistan, which holds the key to the Afghan riddle. Beyond acting as the conflict’s catalyst, the Pakistani side enjoys considerable links to Afghan actors, particularly through extensive support to the Haqqani Network and the Afghan Taliban. Due to obvious strategic advantages, Pakistan has openly and aggressively promoted the perception that the path to peace in Afghanistan passes through Islamabad.

Politically, the Ghani government needs an entente with Islamabad as a means of bringing the Taliban to the negotiating table—an objective it has not been able to achieve despite much effort. It is undoubtedly a commendable achievement that Pakistan and Afghanistan have agreed to resume a bilateral normalization process under Chinese prodding, but they are trapped in a vicious cycle of mutual distrust. Failing to achieve bilateral cooperation on border security, Pakistan is trying to invest a lot in border management. However, without Afghan cooperation, Pakistan cannot secure its border with Afghanistan. The prospects of instigating a peace process will not improve with Beijing’s entry alone. The biggest challenge to Chinese efforts springs from the diametrically opposite positions of the United States and the Taliban. The Trump administration is contemplating a surge in troop levels, intensifying the battle against the Taliban, who continue to insist upon their precondition for joining peace talks: the departure of all Western troops from Afghanistan.

Even as China and Russia press Kabul to begin peace talks with the Taliban, Beijing cannot ignore the policy being adopted by President Donald Trump. The plans for a troop surge signify that the United States is thinking along the lines of defeating the Taliban militarily. Anything that enables the Trump administration to withdraw from the Afghan theater without any catastrophic damage to American credibility will be welcome in Washington, and Trump is unlikely to abandon the United States’ Afghan allies at the mercy of a marauding Taliban and an opportunistic Pakistan.

Particularly when seen from the perspective of the India-obsessed Pakistani military, removing the deep-rooted mistrust between Afghanistan and Pakistan is going to pose a huge challenge for China. Afghanistan has maintained a close relationship with India, which has refused to be part of OBOR, citing serious objections about the CPEC passing through Pakistan-administered Kashmir. Another critical issue is the emerging strategic consensus between the United States and India on regional security issues, which will encourage Delhi to step up its footprint in Afghanistan.

China is well-positioned to facilitate intelligence sharing and border security mechanisms between Pakistan and Afghanistan. Going further, the prospects of launching joint military operations against terrorists in the restive border regions could be explored by the three countries. However, the end state in Afghanistan is going to be determined as much by the dynamics of Afghanistan-Pakistan-India trilateral relations as by U.S.-China relations.

Afghanistan is in disarray largely because of the continuing support, sustenance, and sanctuary to the terrorist network in Pakistan. Clearly, the Afghan conflict is largely a reflection of destabilizing interplay between internal divisions and external interventions. Ever since the 19th century, Afghanistan has been a graveyard of grand diplomatic strategies by outside actors, who have ignored the country’s inherent complexities. Recent U.S. policy has been no exception, and its architects seem to be learning that lesson the hard way. Beijing must take note of this, or it too could find itself drawn into a complex conflict with no easy exit.