Pakistan's foreign policy in a nutshell: As long as China is backing us, we don't have to worry about the United States or the rest of the world. And that was exactly the official reaction after US President Donald Trump announced his Afghanistan policy last month, criticizing safe havens for Islamist terrorists on Pakistani soil.

While the Islamic country's politicians and government officials refuted Trump's claims that Pakistan was supporting militant groups near its border with Afghanistan, they heaved a sigh of relief when Chinese officials came to their support against Trump.

Therefore, it was quite natural for Islamabad to expect that the BRICS nations – Brazil, Russia, India, China and South Africa – would not criticize Pakistan-based militant groups during their recently held summit in the Chinese city of Xiamen.

But after Trump's censure, Xi Jinping's China, too, expressed its worry about the jihadi groups that many experts say are Pakistan's proxies in the region.

"We, in this regard, express concern about the security situation in the region and violence caused by the Taliban, 'Islamic State'(IS)..., al Qaeda and its affiliates, including the Eastern Turkistan Islamic Movement, the Islamic Movement of Uzbekistan, the Haqqani Network, Lashkar-e-Taiba, Jaish-e-Mohammad, TTP and Hizb ut-Tahrir," the BRICS leaders said in a joint declaration.

- Has Trump's Afghanistan policy destabilized South Asia even more?

- Did Afghan minerals change Trump's mind about Afghanistan?

Watch video 01:09 Trump announces new Afghan strategy

A 'message to Pakistan'

Islamabad thus faces a diplomatic dilemma. The BRICS declaration is a victory for the Indian and Afghan stance that Pakistan-based terror outfits pose a serious threat to regional security.

Pakistan's Foreign Minister Khawaja Asif is planning to visit China and Russia in the coming days to garner support for his country in the wake of Trump's criticism. The BRICS statement makes his task more difficult.

"The declaration is a clear message to Pakistan that the international community, including China and Russia, are not ready to tolerate Pakistan's jihadi proxies. We must not forget that Islamist groups also pose a threat to China, which is battling a religiously motivated insurgency in its western Xinjiang province," Dr. Aman Memon, an international relations expert at the Islamabad-based Preston University, told DW.

"The situation is equally alarming for Russia, which is wary of Islamists in Central Asian states," Memon said, adding that it was high time that Pakistan reviewed its policies regarding jihadi groups.

Read more: What is Pakistan's militancy issue all about?

Close allies

New Delhi accuses Pakistan of using jihadi proxies to mount attacks inside India, including India-administered Kashmir. Islamabad denies these allegations.

In February, China blocked a proposal by the US to designate Jaish-e-Muhammad (JeM) chief Masood Azhar a global terrorist. New Delhi accuses JeM and Azhar of masterminding several terrorist attacks on Indian soil, including a deadly assault on an Indian airbase in Pathankot in January 2016. Pakistani investigators say Azhar and his associates had no links to the attack.

Lashkar-e-Taiba (LeT) is another militant group based in Pakistan which New Delhi blames for cross-border attacks including the 2008 Mumbai terrorist attacks that killed 166 people.

Washington has long been demanding that Islamabad relinquishes support for the Haqqani Network, a Taliban ally based in Pakistan's northwestern Waziristan region near Afghanistan.

Now that China has officially expressed its concern about JeM and LeT, the pressure on Pakistan to act against these groups is likely to build.

"The influence of India in Afghanistan is a reason behind Islamabad's support for these militant groups, but after the BRICS declaration Pakistan will come under tremendous pressure to review its policy," Memon said.

New Delhi accuses Pakistan of using jihadi proxies to mount attacks inside India

BRICS statement not detrimental

Experts, however, say that China will keep its leverage over Pakistan, and that it won't isolate Islamabad completely.

Ye Hailin, an expert at the Beijing-based Chinese Academy of Social Sciences, believes hostility between the regional powers could be counterproductive in defeating terrorists.

"As a mediator between Pakistan and Afghanistan, China has always tried to do its best. China's strategic interest in the region is to defeat terrorism," Ye told DW.

China is already part of a Quadrilateral Coordination Group - comprising Afghanistan, China, Pakistan and the United States - that was established to end the protracted Afghan crisis. The grouping has not achieved a significant breakthrough so far, with Islamabad and Kabul at loggerheads over the militancy issue, and the Beijing and Washington relationship lacking in trust.

- What does China want to achieve in Afghanistan?

- 'China and Russia want US out of Afghanistan'

Experts say that China has invested heavily in Pakistan, and that is why it wants peace in at least those areas where its "Belt and Road Initiative" project is being implemented. China has built a port in the southwestern Pakistani province of Baluchistan as part of its nearly $60-billion CPEC project to establish overland and sea trade routes to reach Middle Eastern, European and African markets.

China also wants to minimize India's influence in the region by supporting Pakistan, a policy that experts don't think will drastically change in the near future.

"I think China took Pakistan into confidence over the BRICS declaration. The LeT and JeM have been banned by Pakistan. The Haqqani Network no longer has any presence in Pakistan. We have been cooperating with the US over the Haqqani threat," Amjad Shoaib, a retired army general and defense analyst, told DW.

"People should not read too much into the BRICS declaration and Sino-Pakistani ties," Shoaib added.

Washington believes sanctions could destabilize Pakistan, a nuclear-armed nation with high anti-West sentiments

Engagement with international community

Nonetheless, the BRICS declaration could force Pakistan not to take a collision course with the US.

Pakistanis are confident the international community will continue to rely on its "assistance" in the war in Afghanistan. Washington has so far cooperated with Pakistan, knowing the sanctions or unilateral aerial attacks on the militants' hideouts in the country could further destabilize the nuclear-armed nation with strong anti-West sentiments.

During his tenure, former US President Barack Obama increased drone attacks in Pakistan's northwestern tribal areas bordering Afghanistan, but he continued to engage with Pakistani authorities in order to retain leverage within the country. The flipside to it, analysts say, is that Islamabad has continued with its own strategy for Afghanistan: minimizing New Delhi's influence in Kabul and waiting for complete US withdrawal from the country.

At the same time, some Pakistani analysts say it is in the interest of Islamabad to also keep the Trump administration on its side.

"I think there is no point in getting excited over Trump's Afghanistan policy speech. Pakistan should engage with him [Trump]. He is sending more soldiers to Afghanistan and for that America will need Islamabad's help," Pakistani researcher and defense analyst Aisha Siddiqa, told DW.

Read more: Pentagon acknowledges more US troops in Afghanistan

At the same time, Indian and Pakistani peace activists urge their countries to tread cautiously and not become party to either the US-Chinese rivalry or the global powers' strategic interests in Afghanistan and Central Asia.

Additional reporting by Sattar Khan, DW's Islamabad correspondent.