For years, China had Pakistan’s back as it faced criticism over its alleged support for or inability to curb Islamist militant organizations often accused of fomenting insurgencies and terrorist attacks in neighboring Afghanistan and India.

Beijing now looks ready to publicly prod Islamabad to come clean on the issue in what would be a remarkable change after Chinese officials have reportedly tried to convey the same message privately for some time.

Differences between Beijing and Islamabad over the presence and handling of Islamist militants based in Pakistan are now coming to the fore despite the two capitals being keen on showcasing their alliance as rock solid.

Islamabad is scrambling to limit the fallout from a recent summit of leaders of emerging economies in the BRICS grouping that took place in the Chinese city of Xiamen this week.

In their September 4 statement, the leaders of Brazil, Russia, India, China, and South Africa “expressed concern on 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 (ETIM), the Islamic Movement of Uzbekistan (IMU), the Haqqani network, Lashkar-e Taiba, Jaish-e Mohammad, Tehreek-e Taliban Pakistan, and Hizb ut-Tahrir.

While the statement didn’t name Pakistan specifically, some of the 10 groups still shelter inside the country despite official bans and claims of government crackdowns against them.

Moreover, India, Afghanistan and the United States have frequently asked Islamabad to move against some of the groups. Even those such as ETIM, IMU, IS, and TTP are seen as recruiting from Pakistan or have benefited from sheltering there in recent years.

Differences between Beijing and Islamabad over the presence and handling of Islamist militants based in Pakistan are now coming to the fore despite the two capitals being keen on showcasing their alliance as rock solid.

An overlooked but more revealing change in Beijing’s posture was the condemnation of “terrorist attacks resulting in death to innocent Afghan nationals.”

While calling for an immediate cessation of violence, the BRICS declaration reaffirmed support for Afghanistan: “We support the efforts of the Afghan national defense and security forces in fighting terrorist organizations.”

The declaration appears to be a departure from Beijing’s efforts to publicly defend Pakistan, where it is currently investing more than $50 billion in infrastructure and energy development. Collectively called the China-Pakistan Economic Corridor, these investments are a showcase project of Beijing’s One Road One Belt grand strategy to propel the country’s global reach and influence through trade.

Last month, Chinese State Councilor Yang Jiechi reportedly told U.S. State Secretary Rex Tillerson, "We must value Pakistan's important role in the Afghanistan issue and respect Pakistan's sovereignty and reasonable security concerns."

Yang, who outranks China's foreign minister, spoke with Tillerson on August 23 after U.S. President Donald Trump warned Islamabad that Washington “can no longer be silent about Pakistan’s safe havens for terrorist organizations.”

A day earlier, Beijing was all praise for Pakistan’s counterterrorism efforts. “For many years, it [Pakistan] has made positive efforts and great sacrifices for combating terrorism and made important contributions to upholding world peace and regional stability,” said Hua Chunying, a Chinese Foreign Ministry spokeswoman.

Beijing’s changing stance comes after consistently backing Islamabad on international forums. On Pakistan’s urging, China prevented the United Nations from listing Jaish-e Mohammad leader Masood Azhar as a globally designated terrorist twice this year. The organization is, however, mentioned in the BRICS declaration.

According to Pakistani daily Dawn, in an October meeting Pakistan’s most senior civilian foreign office bureaucrat conveyed a blunt message to the country’s political and military leaders.

Then Foreign Secretary Aizaz Chaudhry, now Pakistan’s ambassador in Washington, told participants that despite its public backing Beijing is pushing for a change in Islamabad’s course.

“Chinese authorities have conveyed their willingness to keep putting on technical hold a UN ban on Jaish-e Mohammad leader Masood Azhar; they have questioned the logic of doing so repeatedly,” the paper reported.

The explosive story stirred a political storm in Pakistan as the country’s powerful army rejected it as a “fabricated” and pushed for a probe, which eventually resulted in several senior civilian officials losing their jobs.

Beijing’s changing stance comes after consistently backing Islamabad on international forums. On Pakistan’s urging, China prevented the United Nations from listing Jaish-e Mohammad leader Masood Azhar as a globally designated terrorist twice this year. The organization is, however, mentioned in the BRICS declaration.

However, there was hardly any official discussion over whether Islamabad needed to change its course.

Pakistani Foreign Minister Khawaja Muhammad Asif, however, confirmed that now even allies are urging Islamabad to clean up its act.

“Did we prove to the world that we are acting 100 percent on the resolve we showed [to end terrorism] in 2014?” he asked in an interview with Pakistan’s Geo television.

Following a massacre at an army school in December 2014, Pakistan civilian and military leadership agreed on a comprehensive National Action Plan on counterterrorism. But the plan’s implementation has been patchy at best.

Asif sees no escape from taking the militant organizations head on.

“As long as we close our eyes to these [terrorist] organizations, we will keep on facing similar embarrassments [such as the one at the BRICS summit],” he said. “Let’s put our house in order and then talk to the rest of the world.”

Pakistan’s top diplomat emphathically rejected the notion that militant organizations such as Lashkar-e Taiba, Jaish-e Mohammad, and the Haqqani network were of any value to his country.

“Every Pakistani must ask whether the people [militants] we nurtured during the past 30 or 40 years are still our [strategic] assets today. Are they our assets or liability? We have to define this on our national level. I am talking about what my children and their children will endure [if we fail].”

Scheduled to soon tour China and Russia, Asif is adamant that the country’s current civilian and military leaders are united in making a clean break with the past.

“First we need to confess our sins and then hope for atonement,” he said.