Analysts believe that it was no coincidence that General Raheel Sharif's visit came at the same time as U.S. President Barack Obama's trip to New Delhi, where he said India is a reliable partner in Afghanistan.
They believe it was a move calculated by Islamabad, to show the U.S., it's close ally in the so-called "War on Terror," that it has other powerful friends.
"The strategic convergence between Pakistan and China is aimed at countering the pressure built up by the U.S.-India partnership in the region, including Afghanistan," General Talat Masood, an Islamabad-based security analyst told The Anadolu Agency.
Pakistan immediately responded to agreements made between the U.S. and India by saying they could be potentially detrimental to the already fragile security balance in South Asia. China's Xinhua news agency also published an editorial questioning whether any genuine results could be produced from Obama's three-day visit.
"The countries have given a clear message that if there are efforts to isolate anyone of them, they will together resist that," said Masood, adding that it is not possible for the U.S. to ignore Pakistan's importance in establishing peace in Afghanistan, despite the two countries' differences of view over the issue.
"There is no clash of interest between India and the U.S. in Afghanistan. But, to an extent, yes, a divergence between Pakistan and the U.S. on some key issues is there," he said. "Taliban are the common enemies of the U.S. and India, however, Pakistan cannot disassociate itself completely from them because it thinks they are a power, especially in southern Afghanistan, and should have a role in the country’s future setup."
Zafar Nawaz Jaspal, the head of International Relations at Quaid-I-Azam International University in Islamabad, thinks that two new geo-strategic alliances are in the offing in South Asia.
"This is a historical U.S. wish to contain China through India. And the latest partnership between U.S. and India is another sequel of this ploy. But China plans to pay U.S. back in the same coin by patronizing Pakistan against India," said Jaspal.
"Whether General Sharif’s visit to Beijing was a coincidence or not, the signaling is very clear," he said. "Pakistan will avail all its options including forming a strategic alliance with China to counter the Indian influence in Afghanistan."
Jaspal disputes however that Pakistan and the U.S. have a clash of interests in Afghanistan.
"Actually, it’s a clash of interest between India and Pakistan. The U.S. wishes to give a role to India in the war-hacked country, to maintain strategic balance but it does not suit Pakistan," he said, adding that China's role is more focused on its own interests.
"China has been actively engaged in Afghanistan because it is worried about a possible spillover of militants into Xinxiang province and some other areas, in case of a permanently destabilized Afghanistan," he said.