At first glance, the resounding defeat of Pakistani President Pervez Musharraf's party in parliamentary elections might seem a setback to the US battle against terrorism.
After all, Musharraf has been a key ally in the fight against al-Qaeda. The election results could bring heavy public pressure to bear on the next Pakistani government to cooperate less with the US.
But there are also reasons for optimism. Pakistan appears headed toward its first elected civilian government after eight years of military rule. And while top Musharraf supporters were repudiated, the winning opposition parties are politically moderate. The vote was also a rebuke to Islamist parties, which lost control of a province where al-Qaeda and Taliban fighters have sought refuge.
The outcome holds the possibility of restoring order in a country whose population is weary of violence.
US President George W. Bush, on a trip to Africa, said: "It's now time for the newly elected folks to show up and form their government. The question then is: Will they be friends of the United States? I certainly hope so."
US officials were cautious in trying to piece together the Pakistan puzzle, including uncertainty over whether Musharraf can survive in power and who exactly will become the country's new prime minister and other top leaders.
"We need Pakistan as an important ally," Bush said. "We've got interests in helping make sure there's no safe haven from which people can plot and plan attacks against the United States of America and Pakistan."
Bush's trip was rocked by three foreign-policy developments in as many days: the Pakistani elections, Fidel Castro's resignation as president of Cuba after nearly half a century in power and Kosovo's declaration of independence from Serbia.
All have ramifications for US policy, with the Pakistani shake-up bearing directly on the US struggle against terrorism.
"Nothing is more important than giving the moderate majority a clear voice and a clear stake in the system," said Senator Joe Biden, the Democratic chairman of the Senate Foreign Relations Committee.
He depicted the election as offering the US a chance to reshape its policy to one less centered on a single leader.
Musharraf and the US have a strained relationship at best.
Since the Sept. 11, 2001, terror attacks, the administration has lionized him as a key ally, a politically moderate leader capable of maintaining order in the world's only nuclear-armed Islamic country.
Under US prodding, he reversed Pakistan's support for the fundamentalist Taliban regime in neighboring Afghanistan and helped round up al-Qaeda militants and the Taliban tribesmen who helped them.
But his path to power -- through a coup in 1999 -- always seemed at odds with Bush's agenda to spread democracy. And some critics have questioned the depth of Musharraf's recent commitment to hunting down militants and pressing the search for Osama bin Laden. Since Sept. 11, the US has given Pakistan some US$10 billion in aid, most of it for the military.
Musharraf is extremely unpopular in his own country, even after he relinquished his rank of army general last year and retired from the military. That unpopularity has stoked anti-US feeling and threatens to erode Pakistan's cooperation in fighting terrorism.
Rick Barton, a Pakistan expert at the Center for Strategic and International Studies, said the role Musharraf will now play is an open question.