ISLAMABAD, Pakistan — Pakistan reacted angrily on Monday to criticism by President Trump that the country had not done enough in return for years of United States military aid and that the government had harbored Osama bin Laden, the leader of Al Qaeda.
In an interview with “Fox News Sunday” this weekend, Mr. Trump defended his decision early this year to withdraw hundreds of millions of dollars in security aid to Pakistan.
“I ended it because they don’t do anything for us, they don’t do a damn thing for us,” he said.
Mr. Trump also alleged that the Pakistani government had known Bin Laden was living in the country before he was killed in an American military raid in 2011.
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.
Despite his criticism, Mr. Khan says that he is not anti-American and stresses that he wants the relationship between the two countries to be based on mutual respect.
The United States and Pakistan enjoyed relatively warmer relations in the years after the attacks of Sept. 11, 2001, when Washington considered Pervez Musharraf, Pakistan’s military ruler until 2008, a close ally. But the relationship turned sour amid mutual mistrust, with officials on both sides accusing each other of not doing enough.
The relationship worsened in 2011 with the American raid on Bin Laden’s compound, which was carried out without Pakistan’s knowledge. Bin Laden had been living in the city of Abbottabad, not far from a military training school.
Pakistani military officials have denied knowing Bin Laden’s whereabouts, arguing that incompetence rather than complicity kept them from alerting the United States. But that has done little to assuage American skepticism.
“Living in Pakistan right next to the military academy, everybody in Pakistan knew he was there,” Mr. Trump told Fox News.
In a series of Twitter posts earlier on Monday, Mr. Khan expressed disapproval of what he called Mr. Trump’s interview “tirade.” Like Mr. Trump, Mr. Khan is fond of using Twitter to make announcements and respond to criticism.
Mr. Khan said Pakistan had joined the United States’ “war on terror” in 2001, even though no Pakistanis had been involved in the Sept. 11 attacks. He said Pakistan had “suffered 75,000 casualties” in that effort and experienced more than $123 billion in economic losses, compared with United States aid of $20 billion.
Mr. Khan added that his country continued to provide the United States with free lines of ground and air communication. “Can Mr. Trump name another ally that gave such sacrifices?” he asked.
Other Pakistani politicians also responded to Mr. Trump’s interview with anger and accusations. Khawaja Muhammad Asif, a former foreign minister, described Pakistan’s relationship with the United States as one of nothing but “betrayal and sanctions.”
Shireen Mazari, the Pakistani human rights minister and a critic of American policy, said on Twitter that Mr. Trump had “perpetual historic amnesia.” She said Mr. Trump’s comments should be a lesson for past Pakistani leaders who had acquiesced to United States demands.
“Once again, history shows appeasement does not work,” she said.