BEIJING: Pakistan, facing a crisis with the United States, has leaned closely to longtime partner China, offering its "all-weather friendship" with Beijing as an alternative to Washington.

But Pakistan will be disappointed if it hopes to replace American patronage with the same from China.

While China does not welcome the US presence near its border, it wants stability on its western flank and believes an abrupt withdrawal of Washington's support for Pakistan could imperil that.

It also does not want to upset warming relations with India by getting mired in subcontinent security tension.

Maintaining that delicate balance, China will continue supporting economic cooperation with Pakistan but go slow on defence cooperation.

While outwardly all smiles and warm pledges of friendship, China will quietly keep things at arms length.

"I think they see what's going on in the US-Pakistan front at the moment as reason to tread very carefully," said Andrew Small, a researcher at the German Marshall Fund think-tank in Brussels who studies China-Pakistan ties and often visits both countries.

"They are taking extra care to make sure that what's going on in the relationship is correctly understood, not reflecting any willingness to rush in or fill the gap or exploit differences."

Pakistan's brittle relationship with the United States, its major donor, has turned openly rancorous. Washington accused Pakistan's powerful ISI spy agency of directly backing the Afghan Taliban-allied Haqqani network and of providing support for a September 13 attack on the US mission in Kabul.

Pakistan has angrily rejected the accusation and warned the United States that it risked losing an ally if it kept publicly criticizing them over militant groups.

Meanwhile, as it often does in times of crisis, Pakistan has been trumpeting its ties with China.

Pakistan's Prime Minister Yusuf Raza Gilani declared Beijing and Islamabad were "true friends and we count on each other" after talks with China's visiting public security minister, Meng Jianzhu.

President Asif Ali Zardari stressed the point last week that Pakistan had other options should its deteriorating relationship with Washington prove beyond repair, and pointedly praised China for its assistance in "stabilizing the situation." Publicly at least, China has gone out of its way to reassure Pakistan.

"Wary Of Offending India"

In May, just weeks after US forces killed Osama bin Laden on Pakistani soil, Premier Wen Jiabao reassured visiting Gilani of their longstanding friendship and spoke of the "huge sacrifices" Pakistan had made in the global struggle against terrorism.

A Chinese Foreign Ministry spokesman echoed that line just last week, saying "Pakistan is on the front lines in the fight against terrorism" and China hoped "the relevant countries respect every country's sovereignty and territorial integrity."

But China's assistance also has limits. "The 'all-weather friendship' doesn't mean that all of Pakistan's bills should be paid by us," said Zhao Gancheng, director of South Asia studies at the Shanghai Institute for International Studies.

"China does not have that ability, nor does the US or any other country. It all depends on Pakistan itself."

China regards Pakistan as an important strategic counterweight against its longstanding rival, India, and a hedge against US influence across the region.

It also wants to use Pakistan as a gateway to the Muslim world and needs Islamabad's help to combat separatists in its far-western Xinjiang region on their common border.

China is a major supplier of military hardware to Pakistan and also a major investor in areas such as telecommunications, ports and infrastructure.

But China's leaders have no desire to turn that limited stake in Pakistan into a heavy security footprint.

"The partnership is as deep as it needs to be for China," Scott Harold, associate political scientist at the RAND Corporation, said. "They've got what they want diplomatically and economically."

During Meng's visit last week, Beijing bolstered its cooperation with Pakistan, with the signing of $250 million in economic and technical agreements, Zardari's office said.

Many of Beijing's deals with Pakistan have had a strategic payoff in helping to balance US influence in the region.

China invested more than $200 million to help build the deep-sea Gwadar port on Pakistan's Arabian Sea coast, partly with a view to opening an energy and trade corridor from the Gulf, across Pakistan to western China.

China also helped Pakistan build its main nuclear power generation facility at Chashma in Punjab province. Two reactors are in operation and two more are planned.

Analysts say China pointedly agreed to expand the Chashma complex to counter a 2008 nuclear energy deal between India and the United States.

But Beijing appears much less interested in a bilateral defence accord, despite a report by Pakistan media that Islamabad had been secretly lobbying for such an agreement.

"I don't think that's the sort of space that the Chinese want to get into," said Small of the German Marshall Fund. "I don't see why they would suddenly want to be stuck with the liability of Pakistan, particularly vis-a-vis India, given the way Pakistan has behaved in a number of crisis situations."

In each of Pakistan's wars with India, China has been fairly restrained, to the point of being almost neutral.

Analysts say China is wary about tilting the relationship too much in favor of Pakistan, to avoid offending India, with which China wants to develop better economic ties.

Annual two-way trade with India was worth $65.2 billion in 2010, compared with bilateral trade with Pakistan of $8.7 billion, according to Chinese statistics.

Ultimately, Beijing has little to gain from a rift between Islamabad and Washington, experts say.

"If US-Pakistan relations deteriorate, and the region falls into instability, China will not be able to shoulder the responsibility by itself and other regional actors will have a difficult time cooperating to restore stability," said Hu Shisheng, an expert on South Asia at the China Institutes of Contemporary International Relations think-tank.

"The US still has to be responsible for the stability of this region."