BEIJING // The words the Pakistani prime minister, Yusuf Raza Gilani, used to describe his country's ties with China earlier this week could not have been more gushing.
The relationship was, he told the visiting Chinese public security minister Meng Jianzhu in Islamabad, "higher than mountains, deeper than oceans, stronger than steel and sweeter than honey".
Pakistan's show of closeness with China came, not coincidentally, when Islamabad's ties to Washington have grown worse.
Admiral Mike Mullen, the soon-to-depart chairman of the US Joint Chiefs of Staff, recently accused Pakistan's Inter-Services Intelligence spy agency of supporting operatives from the Haqqani network, blamed for a series of attacks in Kabul.
In the light of this, Pakistan appeared to be giving the impression that criticism from the United States could send it closer to China, a growing international rival to the US.
The closeness between Pakistan and China, which share a suspicion of US and particularly Indian influence in Asia, dates back decades, extends into military assistance from Beijing and, last year, resulted in the sale of two nuclear reactors to Islamabad. Indeed Pakistan is China's closest ally among Muslim countries.
Ding Xueliang, a foreign affairs analyst at the Hong Kong University of Science and Technology, said: "These are important relations [for China] regardless of Pakistan's problems."
Yet in the face of what some have interpreted as an attempt by Pakistan to cosy up to Beijing following difficulties with Washington, few believe China would consider stepping into the breach and offering the billions of dollars in aid the US has provided Pakistan, and which some US politicians have said should be scaled back further.
Observers say that China's assistance to Pakistan has often fallen short in the past, notably during natural disasters in recent years, when US aid has dwarfed that from Beijing.
Beijing is also unlikely to want to complicate its relationship with India by becoming too close to Pakistan. Nor does it want to create reasons for the US and India to strengthen their ties.
Indeed, according to Pakistani press reports, Beijing rebuffed an attempt earlier this year by Islamabad to forge a defence pact, concerned that its relations with Washington and New Delhi would be jeopardised.
There are also points of contention between Islamabad and Beijing, notably the concern that Uighur militants, who view the Xinjiang region in western China as being under occupation, have received training in Pakistan's Waziristan region, also the stronghold of the Haqqani network.
Earlier this year the Chinese president, Hu Jintao, telephoned his Pakistani counterpart, Asif Ali Zardari, amid concern the Uighur separatist group, the East Turkestan Islamic Movement, was being given free rein in Waziristan. It came after local officials in Xinjiang publicly said Pakistan-trained militants were to blame for an attack there in July.
Last week, Mr Gilani offered China assurances it would crack down on militants.
Certainly analysts believe the issue is much less likely to drive a wedge between China and Pakistan in the way the Haqqani network threatens to derail US-Pakistani relations.
"China appreciates the problems Pakistan is facing in terms of how effectively it can deal with the terrorism problem," said Jia Qingguo, a professor in Peking University's School of International Studies.
"China will continue to encourage Pakistan to fight against terrorism and China will continue to lend support both in rhetoric and material terms. China believes it's also in Pakistan's interests to do more in this regard."
With observers believing China-Pakistan ties will remain strong but somewhat limited by Beijing's caution, Islamabad's recent demonstration of affection may have been largely aimed at unsettling the US. Reports last week said the US secretary of state, Hillary Clinton, had asked her Chinese counterpart, Yang Jiechi, for discussions on Pakistan.
Mr Jia said he did not think Pakistan would be able to play the US and China off against each other.
"Some people in Pakistan may think like that, but I don't think the dynamic works like that," he said.
"China and the US are not competing for Pakistan's favour."