They blame America’s muscular presence — expressed through troops in Afghanistan and espionage and drone operations in Pakistan — for an Islamist surge that has killed tens of thousands of Pakistanis, and they argue that it has been a recruiting tool for militant groups like the Pakistani Taliban.

“Less American involvement is good, not bad,” said Hina Rabbani Khar, who served as foreign minister in the last government, and who said she warmly welcomed the tone of Mr. Obama’s speech on Thursday. “Drones help us lose the war. And the ideological space for these terrorists is the supposed U.S. occupation of Afghanistan. Once that excuse is not there, these people will have to face the music.”

America’s dogged pursuit of fugitives linked to Al Qaeda — first in Pakistan’s cities, later in the tribal belt along the Afghan border — led to a two-faced policy toward Islamist militancy. Pakistani officials secretly accepted, and in some cases encouraged, the American drone program, while condemning it in public as a violation of sovereignty.

Similarly, under pressure from Washington, Pakistan helped the C.I.A. arrest some jihadists, while it quietly sheltered other armed militant groups, like the Afghan Taliban and Lashkar-e-Taiba, who were seen as furthering Pakistani interests in Afghanistan and India.

The American presence also created a giant blind spot in Pakistan’s political psyche: with so much focus on American operations, Pakistani leaders used the United States as a scapegoat to avoid tackling some homegrown problems. Lurid tales of American espionage and other skulduggery abounded in the news media, promoted by politicians and mullahs but also fanned by real-life controversies like the shooting of two Pakistanis by the C.I.A. contractor Raymond Davis in January 2011.

Now that calculus is shifting for Pakistani policy makers. From now on, they will be less able to rely on the cloak-and-dagger workings of the drone program to have it both ways. Indeed, many fear a replay of the early 1990s when, after the departure of Soviet troops from Afghanistan, the United States withdrew abruptly, leaving behind a cadre of fired-up Islamist fighters, and then imposed sanctions on Pakistan for its nuclear weapons program.

Behind the bellicose speech, there is a complex dependency on both sides. While Pakistan’s powerful generals have grown to resent the United States, they also lean on American military aid as a steady source of income in an economy so shaky it may soon require a bailout from the International Monetary Fund. The generals also rely on transfers of American military hardware to keep their fleet of F-16 fighters in the air.