Prime Minister Imran Khan of Pakistan responded by saying that Pakistan had suffered enough fighting terrorism on behalf of the United States.

“Now we will do what is best for our people & our interests,” he wrote on Twitter.

The exchange aggravated an already tense relationship between the two countries.

American officials have long complained that Pakistan has failed to act against terrorist networks operating within its borders; Pakistan denies that the networks are even present. The Haqqani network, which is allied with the Afghan Taliban, is a particular source of friction between the two countries.

Mr. Khan, a populist politician who was elected in July, is a longtime critic of United States policy toward Pakistan, railing against the American use of drones to target militants in the country’s tribal regions. He has accused the Pakistani military of kowtowing to the United States in the past.