* China considering how to work with U.S. on Pakistan
* Washington, Beijing share interests, but views diverge
* Rise in China-India tensions complicates picture
By Myra MacDonald
LONDON, Dec 10 As the United States struggles to work out how to deal with Pakistan, an obvious country to turn to for help is Islamabad's most loyal partner -- China.
Analysts say China shares U.S. concerns about Islamist militants, who have launched a wave of bomb and gun attacks in nuclear-armed Pakistan, and are looking for ways to help stabilise the country.
But Chinese antipathy to interference in others' affairs, a divergence of views on exactly what needs to happen in Pakistan, and China-India rivalry all limit how far Beijing can be roped into helping Washington resolve its Pakistan dilemmas.
"I think the Chinese are still puzzling this stuff out," said Andrew Small, a China expert at the German Marshall Fund of the United States think-tank. "They are trying to work out how you can configure cooperation on Pakistan."
Washington needs all the help it can get on Pakistan as it pushes it to fight Islamist militants, and during a visit to China last month President Barack Obama said both countries had agreed to work together to bring stability to the region.
There is virtually no chance of Beijing sending military forces to Pakistan or Afghanistan. But Chinese support could come in the form of pressure on Pakistan, help for its economy, and at least tacit backing for U.S. actions and demands.
China has been Pakistan's most reliable ally, its financial, diplomatic and military support over the years, including to its nuclear weapons programme, giving it a unique position of trust from which to influence Pakistani policies.
It has big investments there, including building the Gwadar port on Pakistan's Arabian Sea coast to give it access to Gulf oil supplies. It is also wary of any upsurge in Islamist militancy which might spill into its Muslim Xinjiang region.
All this could make Pakistan an area where China could expand its cooperation with the West -- so far dominated by economic ties -- into foreign policy.
"Pakistan is an interesting case where their interests are aligned with other countries," said Small.
But this convergence of ideas goes only so far.
Pragmatically inclined to deal with whoever is in power, China disapproved of Washington's drive to replace former army ruler Pervez Musharraf with a civilian government and has never warmed to his successor, President Asif Ali Zardari.
And while it quietly encouraged Pakistan to go after the Pakistani Taliban, currently the target of a military offensive in South Waziristan, it is sympathetic to Pakistan's argument that it cannot fight all militants at once, analysts say.
Washington is pushing Pakistan also to take on the Afghan Taliban and the anti-India Lashkar-e-Taiba, among others.
But it is Sino-Indian rivalry that really complicates efforts by Washington and Beijing to cooperate on Pakistan.
Optimism some years back that growing trade ties would overcome tensions dating back to China's defeat of India in a 1962 war has dissipated into sparring over their disputed 3,500 km (2,173 mile) Himalayan border.
"Before it was dominated by business opportunities; now it has switched right back to territorial claims," said Gareth Price at the Chatham House think-tank in London.
In the last few months China and India have gnawed away at each other's sense of territorial integrity, quarrelling over border regions including Kashmir in the west, Tibet, and the Indian state of Arunachal Pradesh in the east.
To some extent these are teething problems of two countries which were relatively insular until recently, aggravated by economic competition in which India is always playing catch-up.
"They are getting to know each other," said Price.
But beyond that lies a deeper strategic wariness, with Indian analysts saying China has used its support for Pakistan to distract India and keep its energies focused in South Asia.
In just one example of this triangle of distrust, India developed nuclear weapons in part in response to what it saw as a threat from China. Pakistan developed its own nuclear bombs, with help from China, to counter the perceived Indian threat.
U.S. NEEDS TO LEAD THE WAY
More recently, China has shown a willingness to take a fresh approach to foreign policy in South Asia if it can find a way of both developing trade ties with India while also protecting its commercial and strategic interests in Pakistan.
Over the longer term that could even give China a big enough economic stake in peace in South Asia that it might play a more active role in regional diplomacy, nuancing its approach towards both Pakistan and India accordingly.
It gave a hint of this by supporting a U.N. ban on the Jamaat ud-Dawa, the humanitarian wing of the Lashkar-e-Taiba militant group blamed for last year's attack on Mumbai.
But in the short term, India would be deeply wary of the United States looking for Chinese diplomatic support.
When Obama suggested last month Beijing and Washington cooperate to create "more stable, peaceful relations in all of South Asia", his comments caused a storm of protest in India's media.
And in any case China itself, with its deeply ingrained foreign policy conservatism, is not going to make any diplomatic moves in South Asia unless Washington clearly shows the way.
Small said he saw little sign of China getting itself entangled in the Kashmir dispute between India and Pakistan, as long as this remained off the public agenda in Washington.
He saw recent moves by China to give Indian Kashmiris visas on a separate piece of paper rather than on their Indian passports as part of its broader border row with India rather than an attempt to revive interest in Kashmir. "I don't think they will do this on their own initiative. They will not be a proactive agent," he said. "If it's not a live issue for the Americans, then it won't be for the Chinese." (Editing by Chris Buckley and Robin Pomeroy)