The Bush administration is scrambling to engage with Pakistan's new rulers as power flows from its strong ally, President Pervez Musharraf, to a powerful civilian government buoyed by anti-American sentiment.
Top diplomats John Negroponte and Richard Boucher travelled to a mountain fortress near the Afghan border yesterday as part of a hastily announced visit that has received a tepid reception.
On Tuesday, senior coalition partner Nawaz Sharif gave the visiting Americans a public scolding for using Pakistan as a "killing field" and relying too much on Musharraf.
Yesterday the new prime minister, Yousaf Raza Gilani, said he warned President George Bush in a phone conversation that he would prioritise talking as well as shooting in the battle against Islamist extremism. "He said that a comprehensive approach is required in this regard, specially combining a political approach with development," a statement said.
But Gilani also reassured Bush that Pakistan would "continue to fight against terrorism", it said.
Since 2001 American officials have treasured their close relationship with Musharraf because he offered a "one-stop shop" for cooperation in hunting al-Qaida fugitives hiding in Pakistan.
But since the crushing electoral defeat of Musharraf's party last month, and talk that the new parliament may hobble the president's powers, that equation has changed. Now the US finds itself dealing with politicians it previously spurned.
The body language between Negroponte and Sharif during their meeting on Tuesday spoke volumes: the Pakistani greeted the American with a starched handshake, and sat at a distance .
In blunt remarks afterwards, Sharif said he told Negroponte that Pakistan was no longer a one-man show. "Since 9/11, all decisions were taken by one man," he said. "Now we have a sovereign parliament and everything will be debated in the parliament."
It was "unacceptable that while giving peace to the world we make our own country a killing field," Sharif said, echoing widespread public anger at US-funded military operations in the tribal belt.
"If America wants to see itself clean of terrorism, we also want our villages and towns not to be bombed," he said.
US officials have long paid tribute to the virtues of democracy in Pakistan. But, as happened in the Palestinian Authority after the 2006 Hamas victory, policymakers are racing to catch up with the consequences of a result that challenges American priorities.
The US has long been suspicious of Sharif, whom it views as sympathetic to religious parties. Unlike Benazir Bhutto, whose return from exile was negotiated through the US, Sharif came under the protection of Saudi Arabia. But now Sharif's party, which performed well in the poll, is an integral part of the new government.
Yesterday Negroponte and Boucher travelled to the Khyber Pass in North-West Frontier Province, the centre of a growing insurgency. They met with the commander of the Frontier Corps, a poorly equipped paramilitary force that the US has offered to upgrade. The US has earmarked $750m (£324m) for a five-year development programme in tribal areas. At least 22 military instructors are due to start training the corps this year.
The timing of the American visit - before the new cabinet is announced - has offended Pakistanis. "It flies in the face of normal protocol at a time when public opinion is rife that they are making a last ditch effort to save Musharraf," said Talat Hussain, a prominent journalist.
It is unclear how Pakistan's foreign policy will be formulated in future. Musharraf's power may have been cut but the strong army is lurking in the shadows, and the coalition is wrangling over cabinet posts, including that of foreign minister.
Gilani must manage other tensions, particularly over whether to reinstate Iftikhar Muhammad Chaudhry, the deposed chief justice who was freed from house arrest on Monday. Chaudhry has become a folk hero but is viewed with suspicion by Gilani's Pakistan People's party.