ISLAMABAD, Pakistan — The discovery of Osama bin Laden by American commandos close to the Pakistani capital dealt a devastating blow to the Pakistani military and its intelligence service and set off a fevered round of speculation about how Bin Laden could have been hiding virtually under their noses in a small city that housed military garrisons.

It was amply clear on Monday that the Pakistani military was experiencing a gamut of shock and embarrassment. Pakistan’s official statement, slow in coming, was clearly calculated to put the best face on a moment that threatens to reset relations with the United States.

But the United States’ preoccupation with Pakistan — a nuclear-armed state with rising levels of militancy — revolves around more than Bin Laden, important as he was, and officials on both sides may seek to avoid a sharp turn toward hostility.

Not least, the United States would like Pakistani cooperation in the continuing fight against terrorism and in ending the war in Afghanistan at a moment when Bin Laden’s capture was bound to alter the debate about whether the United States should withdraw from a costly nine-year war.