While the ruins of New York's World Trade Center were still smouldering in late September 2001, President George W. Bush put nations around the globe on notice: "Either you are with us, or you are with the terrorists."
It was an ultimatum that Pakistan's then-president, Gen. Pervez Musharraf, felt acutely as Washington readied for war against the Taliban regime next door in Afghanistan. In his memoirs, he recalls being told by the Americans that "if we chose the terrorists, then we should be prepared to be bombed back to the Stone Age."
Musharraf ditched the Taliban and threw Pakistan's lot in with the United States, making it a strategic ally in the "global war on terror," despite quiet misgivings among his top brass in the powerful military establishment.
Over the decade since then, however, Pakistan has been an erratic and reluctant ally. Trust has crumbled on both sides and, with tensions now running high, it is clear that Islamabad increasingly sees Washington as more of a foe than a friend.
"I'm very pessimistic," said Bruce Reidel, who advised President Barack Obama on policy on Afghanistan and Pakistan. "We're on a downward slide toward a more hostile relationship. Obama wants to save it, but our interests don't coincide."
The dangers could be enormous if Washington fails to arrest the deterioration in relations with Pakistan, a nuclear-armed but largely dysfunctional state run by a feckless, military-cowed government and teeming with Islamist militants.
At stake are the fight against terrorism, the security of Pakistan's nuclear arsenal and - as Islamabad plays off its friendship with China against the United States - regional stability.
The United States and Pakistan have cooperated for decades, first against the Soviet Union and then the al Qaeda network. But anti-Americanism runs deep in Pakistan, in part because of Washington's perceived tilt toward arch-rival, India, but also because of a sense -- heightened by the invasion of Iraq in 2003 -- that the United States is a threat to the Muslim world.
"The U.S. invasion of Iraq, coming on top of U.S. support for Israel and growing ties with India, greatly strengthened the vague and inchoate but pervasive feeling among Pakistanis that 'Islam is in danger' at the hands of the U.S.," wrote Anatol Lieven of the War Studies Department of King's College, London, in a new book, "Pakistan, a Hard Country."
Lieven found that an "absolutely overwhelming majority" of Pakistanis, including the country's elites, do not believe 9/11 was the work of Osama bin Laden's al Qaeda. Many are convinced the attacks were in fact a plot by the Bush administration, Israel, or both, to provide a pretext for the U.S. invasion of Afghanistan as part of a strategy to dominate the Muslim world.
Majid Qurashi, a hospital doctor in the militancy-plagued city of Peshawar on the road to Afghanistan, recently voiced the sentiments many Pakistanis felt on September 11, 2001.
"When I saw the planes crash into the tower, I thought that, finally, someone had decided to teach the United States a lesson and respond to all the bad things it had been doing around the world," he told Reuters.
India has been Pakistan's enemy No. 1 since the violent partition of the subcontinent in 1947. However, hostility toward the United States has grown, reaching new heights after U.S. Navy SEALs killed bin Laden at his Pakistan hideout in May.
Another irritant has been the U.S. drone campaign against militants in Pakistan's tribal badlands on the border with Afghanistan, which Islamabad complains have killed civilians and only encouraged public sympathy for the groups sheltering there.
A Pew Research Center survey of Pakistanis in June found that 69 percent saw the United States as an enemy and 47 percent were "very" worried about a military threat from Washington.
Distrust of Washington is most marked in the army, where there is a sense that - from the Cold War to the war on terrorism - the United States has used Pakistan as a means to pursue its own security interests.
Hussain Haqqani, Islamabad's envoy to Washington, recently asked an audience of mainly military officers by a show of hands, "what is the principle national security threat to Pakistan?": a majority named the United States.
One of the generals who attended a meeting with Musharraf days after 9/11 said that none of the officers openly questioned his decision to side with the United States, but some reminded him "that Americans have a habit of pulling the rug from under our feet once their interests are served."
"America is after our nuclear assets," said the now-retired general, who asked not to be named. "It wants to create chaos in Pakistan to force the United Nations to say Pakistan is an unstable state and cannot secure its nuclear weapons and the international community should take control of these weapons."
There is mounting frustration with the relationship on the U.S. side too, and calls for an end to the security and economic funds that Pakistan receives from Washington, which have added up to some $20 billion since 2001.
This week the White House hailed Pakistan's capture of a top al Qaeda figure as an example of counter-terrorism cooperation.
But it was a rare moment of entente amid U.S. accusations that Pakistan plays a double game over militants on its soil. For many, the fact that bin Laden had been holed up for years in a house just a couple of hours up the road from Islamabad and near a Pakistani military academy said it all.
Pakistan denies any collusion with al Qaeda and regularly reminds Washington that it has paid the highest price in human life and money supporting the U.S. war on militancy.
However, the root of the trust deficit lies with Pakistan's intelligence agency, the ISI, which has a long history of nurturing militant groups to fight India.
Pakistan also stands accused of shielding on its own soil Afghan Taliban, the Haqqani network and others that battle U.S. troops in Afghanistan to guarantee that it has a proxy stake in any political settlement there when American forces withdraw.
"Let me be clear: many Americans died in Afghanistan because of Pakistan's ISI," U.S. senator and naval reservist Mark Kirk fumed this week after an assignment in Afghanistan, proposing "an American tilt" toward India to encourage Delhi to bankroll an Afghan government that could fight terrorism and the ISI.
Ayesha Siddiqa, an expert on the Pakistani military, said the United States and Pakistan have reached a point of strategic divergence as the moment for Afghanistan to stand on its own approaches.
"They can no longer agree on the endgame in Afghanistan," she said. "Both are trying to get the maximum out of each other before that comes."
Embarrassed and feeling betrayed by the secret raid on bin Laden, Pakistan has cut back on U.S. counter-insurgency trainers in the country and placed limits on CIA activities there. Washington responded by suspending about one-third of its $2.7 billion annual defense aid to Islamabad.
"ALL-WEATHER FRIEND" CHINA
In a sign that Pakistan is looking to use its amity with China as a lever in its troubled relationship with Washington, when the prime minister made his first address to the nation on the bin Laden incident he seized the opportunity to lavish praise on "our all-weather friend."
But Beijing's friendship will only go so far.
There is no sign that China is ready to shoulder the financial cost of propping up Pakistan that the United States has so far been willing to bear, and it will calculate that getting too close would tighten strategic ties between Washington and New Delhi, stoking regional tensions.
Despite the tit-for-tat diplomatic sniping between them, Pakistan and the United States are trying to prevent a breakdown of relations. It is proving hard but, for now, both need each other too much to abandon their strategic alliance.
"The United States and Pakistan are going to need to continue to cooperate on counter-terrorism, whether they like it or not," said Stephen Tankel of the Carnegie Endowment for International Peace in an online discussion last week.
"Both sides are not prepared to walk away from the relationship but are beginning to reassess what the nature of that relationship should be going forward."
(Additional reporting by Chris Allbritton, Zeeshan Haider, Michael Georgy and Qasim Nauman in Islamabad, and Warren Strobel in Washington; Editing by Raju Gopalakrishnan)