Pakistan says U.S. criticism of the country's efforts targeting militants works against counterterrorism cooperation between the two allies.

U.S. Defense Secretary Leon Panetta warned Pakistan on Wednesday that the United States will do everything it can to defend American forces in Afghanistan from Pakistan-based militants.

U.S. officials suspect the militant Haqqani network - based in Pakistan's North Waziristan tribal region - was behind Tuesday's 20-hour assault on the Afghan capital. During the deadly attack, militants fired rocket-propelled grenades at the U.S. Embassy and NATO headquarters in Kabul.

Secretary of Defense Leon Panetta

Panetta said Washington has repeatedly urged Islamabad to "exercise its influence" to prevent militants from launching attacks in Afghanistan and then fleeing to safe havens across the border in Pakistan. The U.S. defense secretary said little progress has been made.

On Thursday, Pakistan's Foreign Ministry hit back at Panetta's comments. Ministry spokeswoman Tehmina Janjua said the remarks were "out of line" with the kind of cooperation that exists between the two countries.

Pakistani officials said U.S. and NATO forces should do more to target militants on the Afghan side of the border.

The Pakistani military has been involved in a multi-year campaign against domestic Taliban elements located mostly in the mountainous northwest. Pakistan says its citizens and security forces have borne the brunt of the war on terror with thousands killed over the years in militant violence.

U.S. officials have long urged Islamabad to expand its operation against other groups, such as the Haqqani network, which has ties to both the Taliban and al-Qaida.

Pakistani officials insist that they want to solidify their gains before tackling the North Waziristan tribal area, where the Haqqani network is said to be based.

U.S. drone strikes have targeted Haqqani network operatives in North Waziristan.

Pakistan's spy agency has been suspected of maintaining ties with the Haqqani network, an allegation Pakistan has denied.